Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: how can I combine these expressions?

by chromatic (Archbishop)
on Jul 27, 2000 at 02:44 UTC ( [id://24590]=note: print w/replies, xml ) Need Help??


in reply to how can I combine these expressions?

Why not just stick a ? after each brace? That means 'match zero or one times'. I don't see anything different that happens if the variable's braced, but my brain hurts today so definitely test it first. :)

Update: Okay, the quick-correcting Ovid and lhoward point out the unbalanced problem. The only other thing I can think of is an alternation: (?:{([_a-zA-Z]\w*)}|([_a-zA-Z]\w*)) That part obviously goes after you've found the % sign. It will be more expensive, though. (The * operator hurts.)

Replies are listed 'Best First'.
(Ovid) RE(2): how can I combine these expressions?
by Ovid (Cardinal) on Jul 27, 2000 at 03:02 UTC
    chromatic: sticking a ? after each brace would still allow mismatched braces to be passed through. Since this is user supplied data, I can see a potential for a lot of typos.

    Cheers,
    Ovid

Log In?
Username:
Password:

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

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

    No recent polls found