in reply to Looking for a regex to match last capitalized word in string

The other suggestions may be what hotshot wanted, but they are not what he asked for ... not that it is very clear what he is asking for, but you might do well to consider the differences between this and the other solutions:

for ("siteConfigView", "siteConfigDelete (with ws and lc extras) ") { my $last = (/([A-Z][^\WA-Z]*)/g)[-1]; print "$last\n"; }

Now, s/\*/+/ if that fits your idea of "word" better. And of course, if your string is really long, this version is likely slow. Use with care :-)

The Sidhekin
print "Just another Perl ${\(trickster and hacker)},"

Replies are listed 'Best First'.
(FWP) Re: Re: regexps
by redsquirrel (Hermit) on Mar 26, 2002 at 17:36 UTC
    just for fun...
    for ("siteConfigView", "siteConfigDelete (with ws and lc extras) ") { my $last = (/([A-Z][^\WA-Z]*)/g)[-1]; print "$last\n"; }
    You could collapse the above code into a one-liner: print+(/[A-Z][^\WA-Z]*/g)[-1],$/for"siteConfigView","siteConfigDelete (with ws and lc extras)  " --Dave