Sign in to follow this  

What happened to string::split?

Recommended Posts

zppz    226

The docs and change notes say that the string class should have a split(string delimiter) function, but I can't find any trace of it in the current source code... just wondering what happened to it.


For now I am using this:

string[] split(string str, string delimiter) 
	string[] parts;
	int startPos = 0;
	while (true) {
		int index = str.findFirst(delimiter, startPos);
		if ( index == -1 ) {
			parts.insertLast( str.substr(startPos) );
		else {
			parts.insertLast( str.substr(startPos, index - startPos) );
			startPos = index + delimiter.length;
	return parts;

Share this post

Link to post
Share on other sites
WitchLord    4677

The split method is implemented in add_on/scriptstdstring/scriptstdstring_utils.cpp. 


In order to use it in the scripts you must register it with RegisterStdStringUtils(engine). This call must be done after the string and the script array have been registered.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this