in reply to Re^2: perl system command
in thread perl system command

Might something like this be helpful?

c:\@Work\Perl\monks>perl -wMstrict -le "my $look_for = qr{ (?<! [[:alpha:]]) home (?! [[:alpha:]]) }xms; ;; my $row = 'social_going_home'; my $match = my ($capture) = $row =~ m{ (?<= _) $look_for \z }xmsg; ;; if ($match) { print qq{match, captured '$capture'}; } " match, captured 'home'

Update: BTW: The pattern  feed* in the match of  if(/feed*/) { ... } matches any of  fee feed feedd feeddd ... Is that what you wanted?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^4: perl system command
by cbtshare (Monk) on Nov 10, 2016 at 16:04 UTC
    thank you , I will look at your code .Yes, I wanted feed and any words or digits after, because there is "feed001, feed002" etc
      ... I wanted feed and any words or digits after ...

      /d*/ matches zero or more  'd' characters, but does not match "words" (unless they're composed only of  'd' characters) and certainly not decimal digits. Perhaps you want something like  /feed[[:alnum:]]*/

      c:\@Work\Perl\monks>perl -wMstrict -le "for my $str (qw( feed feeder feed001 xfeed001x fee fee001 xfeex --fee-- fe xxx 001 )) { print qq{'$str' -> }, $str =~ m{ feed [[:alnum:]]* }xms ? '' : 'NO', ' match'; } " 'feed' -> match 'feeder' -> match 'feed001' -> match 'xfeed001x' -> match 'fee' -> NO match 'fee001' -> NO match 'xfeex' -> NO match '--fee--' -> NO match 'fe' -> NO match 'xxx' -> NO match '001' -> NO match
      Change the match pattern above to just  feed* to see the difference.


      Give a man a fish:  <%-{-{-{-<