in reply to Pattern for a single word
Try playing with this:
use strict; use warnings; use feature 'say'; for my $string (<DATA>) { chomp $string; if ( $string =~ / (?<!_) _ ([a-zA-Z]+) $ /x ) { say "Found $1 in $string"; } else { say "No match in $string"; } } __DATA__ He_is_super_hero_Spiderman He_was_a_super_actor_Tom He_was_a_ He_was_a_42 That_nansh_he_was_a_right__one
Besides reading perlretut as suggested by the Anonymous One, you should consider what you are really trying to do here. If your strings really look like this, it indicates that you are doing some awkward text munging with split and join to get to this point. There is almost certainly a better way to do it. You may be suffering from the XY Problem syndrome. You should state what your overall objective is, instead of throwing out these snippets one at a time.
|
|---|