in reply to Pattern matching

If you mean line 'tom blah blah jonh' should match kind of match (eg blah blah can be anything) then this should do it.
m/(?<=tom).*(dick|harry|john)/
But i would think Joost had more readable suggestions.

Replies are listed 'Best First'.
Re^2: Pattern matching
by ikegami (Patriarch) on Jan 05, 2005 at 15:31 UTC

    That doesn't work. Since you don't capture .*, your look-behind is identical to m/tom.*(dick|harry|john)/. You also can't put a regexp inside a look-behind, IIRC.

    ' tom harry ' =~ m/(?<=tom).*(dick|harry|john)/ && print(1, $/); # + 1 ' harry tom ' =~ m/(?<=tom).*(dick|harry|john)/ && print(2, $/); # + (nothing)

    Lookahead works, though

    ' tom harry ' =~ m/(?=.*tom).*(dick|harry|john)/ && print('A', $/); + # A ' harry tom ' =~ m/(?=.*tom).*(dick|harry|john)/ && print('B', $/); + # B
      True. Didn't realize that you could get both sides with lookahead. But I was just trying to get the A part working :).
Re^2: Pattern matching
by Anonymous Monk on Jan 05, 2005 at 13:37 UTC
    what is the significance of "?<=" in your code?
      look at perldoc perlre:

      "(?<=pattern)"<br /> A zero-width positive look-behind assertion. For example, "/(?<=\t)\w+/" matches a word that follows a tab, without including the tab in $&. Works only for fixed-width look-behind.