Playmaker Forum

PlayMaker Feedback => Action Requests => Topic started by: craigz on June 08, 2019, 11:05:15 PM

Title: Get string 'between two characters'
Post by: craigz on June 08, 2019, 11:05:15 PM
Hiya! :D

I went digging all over and can't seem to find this functionality  :) is there a way to get the string characters between two characters? Currently parsing a CSV and there's some nested data between a set of brackets.

Usecase: I'm splitting the string into substrings, but then need to get the data between the [ ]

"Brian,King,Longbeards[enemy],red"

Let me know if I'm missing something that may already exist, totally possible ;D

best,
craigz
Title: Re: Get string 'between two characters'
Post by: djaydino on June 09, 2019, 05:32:52 AM
Hi.

If your [ and ] are only once in the string , you could use 'String Get Index Of' (Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181))
Get index of both [ and ]

Then use 'Get Substring'

You can use the [ index as start index (Possible index + 1)
Then from index ] deduct index [ to get the length (possible +1 or - 1)

I can't test at the moment if 1 needs to be added/subtracted from the indexes,
so you will have to try and find out.
Sorry for that.
Title: Re: Get string 'between two characters'
Post by: craigz on June 17, 2019, 06:18:15 PM
Hmm... that SOUNDS like it should work! :D

Yep the bookend characters are only once per string, though I know that's not always the case for most people :)

I will test this soon and report back, thank you for the insight! :D
Title: Re: Get string 'between two characters'
Post by: cel on November 27, 2019, 02:45:45 PM
Hi, has this worked for you craigz?
Title: Re: Get string 'between two characters'
Post by: jeanfabre on December 04, 2019, 01:07:22 AM
Hi,

 regex must be a far more powerful way to get it done:

https://hutonggames.com/playmakerforum/index.php?topic=7005.0

Bye,

 Jean