LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scan from string

You guys are the Altenbachs of regEx! 

0 Kudos
Message 11 of 16
(1,272 Views)

 


@Darin.K wrote:

You seem to have a lookahead assertion which allows a match of 0 items, basically always true.  If my suspicion is correct, you can eliminate the assertion and make the regex even shorter (\b\w).

 

When I find myself facing a regex in a loop, I try to see if my old friend Search and Replace can help.

 

InitialsRegex.png

 


 

I just tried this and the result that I got was the full name as the initials. Am I missing something?

 

Update: Never mind. I forgot to check the regular expression option on the search and replace.

 

(I did have to recreate the VI by hand since snippets aren't working with Firefox.)



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 12 of 16
(1,245 Views)

 


@Mark Yedinak wrote:

 

Update: Never mind. I forgot to check the regular expression option on the search and replace.

 


Don't feel bad, I had the same thing happen to me earler with another VI.  I think it was also from Darin.  😉

 

0 Kudos
Message 13 of 16
(1,237 Views)

@Darin.K wrote:

You seem to have a lookahead assertion which allows a match of 0 items, basically always true.  If my suspicion is correct, you can eliminate the assertion and make the regex even shorter (\b\w).

  


You're right, \b\w works. Thanks for the tip of replacing the while loop with the search and replace function and the use of the special character $n.

 

I think the regex used can be simplified to \W*(\w)\w* (but in both cases if you have John Q. the output will be JQ. not eliminating the final dot). To eliminate the final dot \W*(\w)\w*\.* or \W*(\w)[\w\.]* can be used.

 

Ben64

Message 14 of 16
(1,227 Views)

@Mark Yedinak wrote:

 

[...]

 

(I did have to recreate the VI by hand since snippets aren't working with Firefox.)


Here's a Quick Drop plugin to help you use snippets from Firefox.  It fetches the snippet from the URL comment.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 15 of 16
(1,225 Views)

 


@Ray.R wrote:

 


@Mark Yedinak wrote:

 

Update: Never mind. I forgot to check the regular expression option on the search and replace.

 


Don't feel bad, I had the same thing happen to me earler with another VI.  I think it was also from Darin.  😉

 


 

Ha Ha, half of the time I forget to check that before running the first time.  I actually thought of Ray.R and came close to mentioning that fact, but snippets make me lazy about that.  Besides, once you see the before and after of that selection you recognize it pretty quickly.

 

Hint:  If you see me using that function, rest assured that Regexes are enabled.  Smiley Tongue

0 Kudos
Message 16 of 16
(1,211 Views)