Hi,
Here are some shared code :
RegEx (namespace ArqWx) is a C++/wxWidgets class which extends capacities of wxWidgets regular expressions
management. It is designed to work with wxWidgets' wxRegEx class, and adds these functionalities:
- processes whole text with a single regex pattern, thus it can extracts as many matches are
contained into whole text;
- extracts named groups.
For details, please read included text file.
-----
Name grouping
Doc extract:
example 1:
Code: Select all
1 ArqWx::RegEx myTRE("^.+/(?<filename>[^.]+).(?<extension>[^?]+).+");
2 ::wxMessageBox(myTRE.Groups("http://www.site.net/Smtg/Another/Forums/AddPost.aspx?tabindex=1", "filename"));
3 ::wxMessageBox(myTRE.Groups("http://www.site.net/Smtg/Another/Forums/AddPost.aspx?tabindex=1", 2));
Line 3 will display "aspx".
example 2:
Code: Select all
1 ArqWx::RegEx myTRE("^.+/(?<filename>[^.]+).(?<extension>[^?]+).+", "http://www.site.net/Smtg/Another/Forums/AddPost.aspx?tabindex=1");
2 ::wxMessageBox(myTRE.Groups("extension"));
3 ::wxMessageBox(myTRE.Groups(1));
Line 3 will display "AddPost".
-----
Whole text processing
Doc extract:
example 1:
Code: Select all
1 ArqWx::RegEx myTRE("/([^/]+)");
2 ::wxMessageBox(wxString::Format("%d", myTRE.GetTotalMatchCount("http://www.site.net/Smtg/Another/Forums/AddPost.aspx?tabindex=1")));
3 ::wxMessageBox(myTRE.GetTotalMatch("http://www.site.net/Smtg/Another/Forums/AddPost.aspx?tabindex=1", 2));
Line 3 will display "Smtg".
example 2:
Code: Select all
1 ArqWx::RegEx myTRE("/([^/]+)", "http://www.site.net/Smtg/Another/Forums/AddPost.aspx?tabindex=1");
2 ::wxMessageBox(wxString::Format("%d", myTRE.GetTotalMatchCount()));
3 ::wxMessageBox(myTRE.GetTotalMatch(4));
Line 3 will display "Forums".
----
I cannot guarantee this class is bug-free, but all tests i have performed were ok.
Feel free to use this class and to send me some reports, especially if you find bugs !!