Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: How to substitute something from only between two specified charecters (sub_question)

by wind (Priest)
on Jun 29, 2011 at 19:37 UTC ( #912020=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How to substitute something from only between two specified charecters (sub_question)
in thread How to substitute something from only between two specified charecters

I wrote the regex that way to have an explicit boundary between the second field and the spacing separating it from the third field. I didn't want to eat any extra spacing.

I could have accomplished this in one of three ways:

  1. 1) Explicitly specify that the field shouldn't contain a space at the end like I did. (.*\S)\s+
  2. 2) Use an explicit boundary like (.*)\b\s+
  3. 3) Or rely on non-greedy matching: (.*?)\s+ Which would work because of the hard boundaries for the other fields

In the end, the third method above would probably appear the cleanest, but they all accomplish the same thing in the context of the rest of the regex.


Comment on Re^3: How to substitute something from only between two specified charecters (sub_question)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-08-30 09:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls