in reply to A Better Way to Find the Position of the Last Non-Whitespace Character in the Last Element of an Array.

How about a look-ahead containing a capture?

$ perl -le ' > @strs = ( q{abcd }, q{abcdef}, q{ } ); > print qq{String: >$_< - }, > m{(?=(\S)\s*$)}g > ? qq{found $1 at offset @{ [ pos() ] }} > : q{no match} > for @strs;' String: >abcd < - found d at offset 3 String: >abcdef< - found f at offset 5 String: > < - no match $

I hope this is of interest.

Cheers,

JohnGG

  • Comment on Re: A Better Way to Find the Position of the Last Non-Whitespace Character in the Last Element of an Array.
  • Download Code