Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Regexing a block of text in between patterns

by CountZero (Bishop)
on Mar 10, 2009 at 17:15 UTC ( [id://749656]=note: print w/replies, xml ) Need Help??


in reply to Re: Regexing a block of text in between patterns
in thread Regexing a block of text in between patterns

Or rather
my @sidenotes = split /\[Sidenote:.*?\]/, $text;
Otherwise you will leave some junk at the beginning of each block.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^3: Regexing a block of text in between patterns
by mwah (Hermit) on Mar 10, 2009 at 18:03 UTC

    Hello CountZero

    Otherwise you will leave some junk at the beginning of each block

    I purposely included the [Sidenote] text after understanding the OP's specification this way.

    Maybe I didn't read closely enough ...

    Thanks & Regards

    mwa

      Now that you say it I looked again at his regex and indeed one could think that "[Sidenote:" is the breakpoint, which does not fully tally with his question.

      Well, he now has both options to choose from!

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 10:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found