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 Loops (Curate)
on Apr 12, 2013 at 14:37 UTC ( [id://1028385]=note: print w/replies, xml ) Need Help??


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

Hi

Assuming you want the period or parenthesis character to be the same on each end of the match, the following code works:

use warnings; use strict; use feature 'say'; while (<DATA>) { chomp; if (/1([)|\.])(.*)(2\1)/) { say $2; } else { say "BAD LINE:", $_; } } __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)

Log In?
Username:
Password:

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

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

    No recent polls found