RegEx
Fabian Cenedese
Cenedese at indel.ch
Wed Jan 30 23:32:20 PST 2008
At 18:35 30.01.2008 +0100, Zorro wrote:
>> wxString text;
>> wxRegEx reEmail = wxT("([^@]+)@([[:alnum:].-_].)+([[:alnum:]]+)");
>>
>> if ( reEmail.Matches(text) ) { // <---!!!
>> wxString text = reEmail.GetMatch(email);
>> ...
>>
>> You need to call Matches() before GetMatch().
>
>ok , what is email? wxString regex or flag?
>
>
>I need get substring and count (GetMatchCount) of substrings.
>Please wrote simple example
You can look at the example yourself:
http://www.wxwindows.org/manuals/stable/wx_wxregex.html#wxregex
But I think there's a small error in it. I think it should be:
wxString email("someaddress at example.com");
wxRegEx reEmail = wxT("([^@]+)@([[:alnum:].-_].)+([[:alnum:]]+)");
if ( reEmail.Matches(email) ) {
wxString text = reEmail.GetMatch(email); // whole address
wxString username = reEmail.GetMatch(email, 1);
wxString domain = reEmail.GetMatch(email, 2);
wxString tld = reEmail.GetMatch(email, 3);
...
bye Fabi
More information about the wx-users
mailing list