ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

find string between two characters -- regex?

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.

0 Kudos
Message 1 of 4
(5,974 Views)

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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 4
(5,964 Views)

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.

RegExpToken.png

You do end up with a space at the begging of the SubString output if the offset is greater than 0 zero.

Omar
0 Kudos
Message 3 of 4
(5,943 Views)

@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.

0 Kudos
Message 4 of 4
(5,931 Views)