Hi,
I need and expression for a word like abc_xyz_ykklm The expresion should indicate that the word starts with abc and end with ykklm but does not contain xyz string in the middle. Example: abc_tmn_ykklm is ok and abc_xyz_ykklm is not Ok.
Please help.
Regards.
% ./s enter string: abc_tmn_ykklm abc_tmn_ykklm is ok enter string: abc_xyz_ykklm abc_xyz_ykklm is not ok
% cat s #!/usr/bin/perl use warnings; use strict; my $p = qr/^abc_(?!xyz)[^_]*_ykklm$/; while (1) { print "enter string: "; my $s = <>; chomp $s; print "$s is ", $s =~ /$p/o ? "" : " not " , "ok\n"; }