Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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 ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://912020]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-18 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found