Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Regex: Matching around a word(s)

by pKai (Priest)
on Dec 20, 2005 at 10:46 UTC ( [id://518018]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    use Data::Dumper ();
    ...
    lookahead/lookbehind, but they don't capture.  Is there a way
    to do this with a single regex?  Is a regex even the best way
    to do this?  Thanks, -Lee
    
  2. or download this
    perl -Mstrict -Mwarnings context.pl is and the have
    $matched = [
    ...
      'a single regex?  [Is] a regex even [the] best way
    to do this'
    ];
    
  3. or download this
    \b              # a word boundary
    (?!\s)          # following char is not a white space (1)
    ...
        \b          #    up to the next word boundary
      )
    )
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-23 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found