02-22-2011 06:05 PM
You guys are the Altenbachs of regEx!
02-23-2011 09:51 AM - edited 02-23-2011 09:57 AM
@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.
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.)
02-23-2011 10:04 AM
@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. 😉
02-23-2011 10:53 AM
@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
02-23-2011 10:54 AM
02-23-2011 11:13 AM
@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.