perl - Regex find a substring in a string containing a pattern -
so if string $a = "blah bluh bu.du" check if string has du in using:
if( $a =~ /\.du+/)
now confirmed string has ".du" in it. how can word budu saved new string $b? using perl sorry, du supposed file extension
surround part want capture in parenthesis.
if( $a =~ /([a-za-z]*?du[a-za-z]*?)/){ if ( defined $1 ) { $word = $1; print "$word\n"; } }
Comments
Post a Comment