Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: What is regular expression for the following thing?

by Corion (Patriarch)
on Oct 20, 2008 at 09:08 UTC ( [id://718169]=note: print w/replies, xml ) Need Help??


in reply to What is regular expression for the following thing?

You have an error with precedence in your regular expression. The alternation (|) doesn't know where you want it to stop. See YAPE::Regex::Explain if you want a module that explains regular expressions to you.

Your regular expression currently matches like

(?-imsx:^REGISTER|INVITE|BYE\s\w\.\w\sSIP/2.0) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- REGISTER 'REGISTER' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- INVITE 'INVITE' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- BYE 'BYE' ---------------------------------------------------------------------- \s whitespace (\n, \r, \t, \f, and " ") ---------------------------------------------------------------------- \w word characters (a-z, A-Z, 0-9, _) ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- \w word characters (a-z, A-Z, 0-9, _) ---------------------------------------------------------------------- \s whitespace (\n, \r, \t, \f, and " ") ---------------------------------------------------------------------- SIP/2 'SIP/2' ---------------------------------------------------------------------- . any character except \n ---------------------------------------------------------------------- 0 '0' ----------------------------------------------------------------------

Maybe you want the Net::SIP module instead of writing your own module?

As an aside, putting your code between <code>...</code> tags makes the code render and download nicely for those who want to try it.

Update: YAPE::Regex::Explain installed and I updated the explanation

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://718169]
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: (2)
As of 2024-04-26 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found