Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

String parsing / tokens / split

I was sure I had gotten this working once but it could just be various languages blurring in my head..

I know that we can split strings in Twine2 (Harlowe) using the original (substring:) and the new "abcde"'s (a: 2,4) , but both require a range of start-to-end to extract.

And there is (count:) for how many times something appears and (contains:) for checking if something exists, and I think there was even an index somewhere that I'm not finding right this second..

What I cannot seem to find anywhere though (and maybe its because the search parameters are just too common to search effectively on google / here / twine2.neocities.org is:

How do you take a string (eg: "Hello World Foo") and get it converted into an array with a the delimiter (eg. " ")?

I know the long (and slow) way of doing it might be to go character by character searching for the token, than get the substring from 'start' to 'current-1' or something, but that is really ugly. The hard fast way might be to go back and figure out how to do the twine-javascript bit but I am trying to not keep mixing languages (why I've been so excited by Twine).. Is there something already in place so I don't have to figure out how to reinvent the wheel? :)

Much thanks!

Comments

Sign In or Register to comment.