[Qt-interest] Problem with qregexpr

Alexandre Beraud aberaud at infflux.com
Tue Oct 6 09:41:30 CEST 2009


Hi,

Well, if you write this:

QString myString = "--DUMMY";
QRegExp re("--\\s*STRING");

Then re.exactMatch(myString)) should never return true. Is that what 
your code looks like ? The hyphen (-) has no special meaning outside of 
a character class, afaik.

Regards,

Alex


matteo a écrit :
> If I use QRegExp::exactMatch() with the pattern ("--\\s*STRING"), it 
> matchs with "--DUMMY" and not only with "--STRING". I need that it 
> matchs only with "--STRING" or "--    STRING" with many space from -- 
> and STRING.
>
> Regards
>
> Teo
>
> Alexandre Beraud wrote:
>   
>> Hi,
>>
>> If you use QRegExp::exactMatch(), then you don't need ^ and $ around 
>> your text since they mark the beginning and the end of the string. Also, 
>> \b has no size _but_ it does represent something: the boundary between a 
>> word character (\w) and a non-word character (\W). - is not a word 
>> character, thus \b-- won't match unless you have something like: A--STRING
>>
>> Regards,
>>
>> Alex
>>
>>
>> matteo a écrit :
>>
>>     
>>> Hi,
>>> I have the string
>>>
>>> --STRING
>>>
>>> If I try to match whith QRegExp("--\\s*STRING") it runs, but if I try 
>>> with  QRegExp("\\b(--\\s*STRING)\\b") it doesn't match.
>>>
>>> Where is my mistake?
>>>
>>> Thanks
>>> Teo
>>> _______________________________________________
>>> Qt-interest mailing list
>>> Qt-interest at trolltech.com
>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>
>>>
>>>   
>>>       
>>
>>     
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>   


-- 
Alexandre BERAUD
Ingénieur Développement

Infflux - Informatique & Flux
Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
Mail: aberaud at infflux.com
Visitez notre site :  www.infflux.com




More information about the Qt-interest-old mailing list