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 ( #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!


Comment on Re: regular expression for getting text between 1. and 2.
Select or Download Code

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: (8)
As of 2014-12-28 20:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (182 votes), past polls