02-28-2011 02:26 PM - edited 02-28-2011 02:28 PM
So this seems like a regex type thing, but I'm still incredibly regex illeterate. If I have an offset in a string, I want to find all words separated by the space before and the space following that location.
For Example:
"This is a string of multiple characters"
If my cursor was between the o and the f in "of" i would want to return "string of multiple". I can then split this into an array of words using "\s" as a delimeter. I just need to get the substring shown.
02-28-2011 02:48 PM
Or you split the string at the Offset, reverse the first half, look for the 2nd space in each (which can be a regex, similar to [^\s]*[^\s]*) then revese back and recombine. 🙂
/Y
02-28-2011 03:57 PM - edited 02-28-2011 03:59 PM
What do you want to happen if the cursor is at the very beginning?
What if the cursor is between the space and the o in "of" (at the beginning of a word)?
I thought "Find Token" would work but I was wrong.
You do end up with a space at the begging of the SubString output if the offset is greater than 0 zero.
02-28-2011 04:34 PM
@Yamaeda wrote:
Or you split the string at the Offset, reverse the first half, look for the 2nd space in each (which can be a regex, similar to [^\s]*[^\s]*) then revese back and recombine. 🙂
/Y
Droppin' knowledge.