This Question is Answered

15 "helpful" answers available (3 pts)
4 Replies Last post: Oct 15, 2008 6:39 AM by RajivGu

Is RegX in curl follow different rule then standard specification?

Sep 26, 2008 4:47 AM

Click to view RajivGu's profile Level 6 RajivGu 81 posts since
Apr 2, 2008
Hi,

I have formed reg.expression using expresso (Tool to create Regular expression.)


I want to use that regular expression in curl, I m getting error while compiling the code.


I want to parse the string D1 20080929T000000Z using following regx,


 
 
 
D(?<interval>[0-9].*?)\s.*?(\#(?<occurance>[0-9]{1,2})|(?<enddate>([0-9]{8}[T]{1}[0-9]{6}[Z]{1})))
 
 

In expresso it shows that expression is valid for above rule,but same regx showing error in curl.


Thanks


Rajiv

Click to view cbarber's profile Curl cbarber 115 posts since
Sep 27, 2007
1. Re: Is RegX in curl follow different rule then standard specification? Sep 26, 2008 7:12 AM
First, there is no "standard" regular expression specification. There are many different regular expression implementations with slightly different escaping rules and special features. The problem is that Curl does not support the more recently introduced (?<name>...) syntax for named subgroups. This was originally an extension introduced in the Python language's regular expression implementation, where it used the syntax (?P<name>...), and that is what we support in Curl (it is also supported in Perl). There are a number of other extensions in Perl that have not yet made it to Curl, so you should always check the Curl documentation to see if the feature you want to use is supported.

Also note that both Curl and Perl differ from .NET in that subgroups are numbered regardless of whether they are named, while in .NET they are not. So that given the expression

(?<foo>x)(y)


the group containing 'y' would be numbered 2 under Curl or Perl but would be numbered 1 under .NET.
Click to view RajivGu's profile Level 6 RajivGu 81 posts since
Apr 2, 2008
2. Re: Is RegX in curl follow different rule then standard specification? Sep 30, 2008 2:52 AM
in response to: cbarber

Thanks for replying!!!

Is there any tool available for creating RegX for curl language?

As I am new to this i dont know all the rule of creating RegX.

So Expresso like tool for curl would be helpful for me.

Thanks

Rajiv

Click to view cbarber's profile Curl cbarber 115 posts since
Sep 27, 2007
3. Re: Is RegX in curl follow different rule then standard specification? Sep 30, 2008 6:06 AM
in response to: RajivGu
There is no tool for building regular expressions in Curl, but if you are not using advanced features like named groups you can probably use tools like expresso.

The Curl Developer's Guide chapter on regular expressions also contains executable examples that make it easy to try out a regular expression, so you might try that.
Click to view RajivGu's profile Level 6 RajivGu 81 posts since
Apr 2, 2008
4. Re: Is RegX in curl follow different rule then standard specification? Oct 15, 2008 6:39 AM
in response to: cbarber

Thanks for your valueable input over the REgX.

Thanks

Rajiv