I have a long string that I want to parse and retrieve a value.
I was thinking of using patterns but I am a bit rusty at this.
This is the part of the string that interests me:
…sinking will be 44% successful…
the word ‘sinking’ is the keyword. I am looking to get the percentage value(44% in this case)
What is the best way?
Thank you.
** the words ‘will be’ may change.
Here’s a regex solution:
If you want just the numeral value of the percent, change your pattern to this:
If any of the preceding text is irrelevant, you just want to grab the percent in a line, use this pattern:
Edit: If your keyword is “sinking”, and you want the first percentage value after this word, this would be your pattern: