xerces-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alberto Massari <amass...@datadirect.com>
Subject Re: patternMatch and regular expression syntax
Date Wed, 02 Sep 2009 13:31:19 GMT
Hi Thomy,
it tuns out that XMLString::patternMatch is not a pattern-matching 
method, but more a "find string" API. In order to do what you need you 
must use the RegEx class, like in

        RegularExpression p("PAG_[0-9]{1,}");
        bool bMatch=p.matches("PAG_1");

Alberto

Thomy wrote:
> Hi Alberto,
>
> I use the last version in the download area, i guess it's the 3.0.1
> available here : http://xerces.apache.org/xerces-c/install-3.html#Unix
> Maybe i misunterstood the use of patterMatch method, i checked the source
> code and it doesn't seem to use regexp ...
> Is there something to do with regExp before using them like a pattern, like
> a compile method like in java ?
>
> thanks for your answer and your help !
>
>
> Alberto Massari wrote:
>   
>> Hi Thomy,
>> I tested your regex with the current trunk of Xerces 3.0, and it works; 
>> which version are you using?
>>
>> Alberto
>>
>> Thomy wrote:
>>     
>>> Hi !
>>>
>>> I'm trying to use XMLString::patternMatch to check syntax of XMLString
>>> gived
>>> by a user.
>>>
>>> i made a pattern to recognize an id : PAG_[0-9]{1,}
>>> My test id is PAG_1
>>> i call patternMatch with an XMLString containing "PAG_1" and check with
>>> this
>>> pattern :
>>> const XMLCh AltoXMLConst::validPage[] =
>>> {
>>> 	chLatin_P,chLatin_A,chLatin_G,chUnderscore, chOpenSquare, chDigit_0,
>>> chDash, chDigit_9, chCloseSquare, chOpenCurly, chDigit_1, chComma,
>>> chCloseCurly, chNull
>>> };
>>>
>>> it's return -1. I guess i have a syntax problem because if i made a
>>> pattern
>>> which is "PAG_" it's return 0.
>>> Is there a problem with my syntax of "any number from 1 to infinite", how
>>> to
>>> write it well ?
>>>
>>> Thx in advance for your help
>>>   
>>>       
>>
>>     
>
>   


Mime
View raw message