Reply To: need grep help

#82665
Peter Kahrel
Participant

This is a tricky one. First of all, you need to escape the asterisk in your lookahead: use (?=\*), not (?=*) (because you’re after the * character literally, you don’t want to use it as an operator).

But when you’ve fixed that you’ll find that the expression matches “jim q. public, MD” (as expected) and “Cindy E. Verybody, MD; Jill Neigh Bor,MD” (not expected). What you need to do is match from ; to * without any intervening ;. You can do that with this expression:

(?<=;)[^;]+?(?=\*)

Peter

This article was last modified on March 6, 2016

Comments (0)

Loading comments...