Sign in to follow this  

What happened to string::split?

This topic is 1773 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

 

http://www.angelcode.com/angelscript/sdk/docs/manual/doc_datatypes_strings.html

http://www.angelcode.com/angelscript/changes.php

 

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) );
			break;
		}
		else {
			parts.insertLast( str.substr(startPos, index - startPos) );
			startPos = index + delimiter.length;
		}
	}
	return parts;
}

Share this post


Link to post
Share on other sites

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

oh... not sure how I managed to miss that. Thanks!

Share this post


Link to post
Share on other sites

This topic is 1773 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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