Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by Kenosis (Priest)
on Apr 12, 2013 at 17:04 UTC ( #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
Node Status?
node history
Node Type: note [id://1028423]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2016-06-27 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (337 votes). Check out past polls.