Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Match last word in a sentence

by eyepopslikeamosquito (Bishop)
on Aug 14, 2021 at 00:06 UTC ( #11135834=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
    my $the_rest = $1;
    print "the_rest='$the_rest'\n";
    print "last='$last'\n";
    
  2. or download this
    the_rest='This is my lis'
    last='t'
    
  3. or download this
    $list =~ /
        ^(.+)    # The 'rest' (Everything before last word)
        \b(\w+)  # Last 'word' (string of contiguous word characters)
        \W*$     # Possible non-word characters at end of string
    /x;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11135834]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2022-05-29 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?