Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: regular expression for getting text between 1. and 2.

by Kenosis (Priest)
on Apr 12, 2013 at 17:04 UTC ( [id://1028423]=note: print w/replies, xml ) Need Help??


in reply to regular expression for getting text between 1. and 2.

In the cases you've shown, there's whitespace enclosing the text you want, so you can use a lookbehind and lookahead to capaure the enclosed text:

use warnings; use strict; while (<DATA>) { print "$1\n" if /(?<=\s)([a-z\s]+)(?=\s)/i; } __DATA__ 1) some text 2) 1. some text 2. 1) some text 2. 1. 2.10.10.20 some text 2. 1) 2.10.10.20 2)

Output:

some text some text some text some text

Hope this helps!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-25 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found