playMaker

Author Topic: Get string 'between two characters'  (Read 151 times)

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 189
    • View Profile
    • Haven Made
Get string 'between two characters'
« on: June 08, 2019, 08: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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4323
    • View Profile
    • jinxtergames
Re: Get string 'between two characters'
« Reply #1 on: June 09, 2019, 02:32:52 AM »
Hi.

If your [ and ] are only once in the string , you could use 'String Get Index Of' (Ecosystem)
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.
FOR HIRE:Playmaker/C#

Playmaker Samples <-------------> Easy Exporter <---------------------> TPA Actions

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 189
    • View Profile
    • Haven Made
Re: Get string 'between two characters'
« Reply #2 on: June 17, 2019, 03: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