#include <wx/regex.h>
#include <wx/textfile.h>
void RegExDemoFrame::OnAbout(wxCommandEvent& event)
{
wxRegEx ex;
wxString pattern = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\.\\w+([-.]\\w+)*";
if (ex.Compile(pattern,wxRE_ADVANCED))
{
wxString email = "dqifa@163.com";
if (ex.Matches(email))
{
wxMessageBox("email is valid/n");
// wxMessageBox(ex.GetMatch(email));
}
else
{
wxMessageBox("email is not valid/n");
}
}
// wxRegEx r;
// wxTextFile f;
r.Compile(_("^([a-z|A-Z|_][a-z|A-Z|_|0-9|\\*|&]*)\\s+([a-z|A-Z|_][a-z|A-Z|_|0-9|:|\\.]*)\\s*\\(.+$"), wxRE_ADVANCED);
// r.Compile("^\/\/[^\n]*[\n]? ");
// f.Open("function.cpp");
// if(f.IsOpened())
// {
// wxString line,s;
// while(!f.Eof())
// {
// line=f.GetNextLine();
// if(r.Matches(line)) s<<line<<"\n";
// }
// wxMessageBox(s);
// f.Close();
// }
}
wxRegEx的使用
最新推荐文章于 2021-06-02 16:22:10 发布