in reply to Looking for a regex to match last capitalized word in string
$_="ConfigState"; my @words= split /([A-Z][^A-Z\s]+)$/,$_; print @words[-1], "\n"; # prints "State" # @words = qw(Config State) @words= split /([A-Z])/,$_; print @words[-2,-1], "\n"'; # It's a trick, but it prints "State" # @words = qw(C onfig S tate)
|
---|