http://www.perlmonks.org?node_id=548908


in reply to What this pattern matches

$b='This_is_Sample_Text'; if ($b=~/^(.+)_[^_]+$/) { print "\n$1"; ## This_is_Sample }

. = Match any character (except newline)

+ = Match 1 or more times

.+_ = Match upto last underscore(_)

[^_]+$ = Notmatch underscore(_) upto end of the string