added wxRegEx::GetMatch
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
// flags for regex compilation: these can be used with Compile()
|
||||
enum
|
||||
{
|
||||
// use extended regex syntax: default
|
||||
// use extended regex syntax (default)
|
||||
wxRE_EXTENDED = 0,
|
||||
|
||||
// use basic RE syntax
|
||||
@@ -51,7 +51,7 @@ enum
|
||||
wxRE_NEWLINE = 16,
|
||||
|
||||
// default flags
|
||||
wxRE_DEFAULT = wxRE_NOSUB | wxRE_EXTENDED
|
||||
wxRE_DEFAULT = wxRE_EXTENDED
|
||||
};
|
||||
|
||||
// flags for regex matching: these can be used with Matches()
|
||||
@@ -97,14 +97,24 @@ public:
|
||||
// TRUE if matches and FALSE otherwise
|
||||
//
|
||||
// flags may be combination of wxRE_NOTBOL and wxRE_NOTEOL
|
||||
//
|
||||
// may only be called after successful call to Compile()
|
||||
bool Matches(const wxString& str, int flags = 0) const;
|
||||
|
||||
// get the start index and the length of the match of the expression
|
||||
// (index 0) or a bracketed subexpression (index != 0)
|
||||
//
|
||||
// may only be called after successful call to Matches()
|
||||
//
|
||||
// return FALSE if no match or on error
|
||||
bool GetMatch(size_t *start, size_t *len, size_t index = 0) const;
|
||||
|
||||
// return the part of string corresponding to the match, empty string is
|
||||
// returned if match failed
|
||||
//
|
||||
// may only be called after successful call to Matches()
|
||||
wxString GetMatch(const wxString& text, size_t index = 0) const;
|
||||
|
||||
// replaces the current regular expression in the string pointed to by
|
||||
// pattern, with the text in replacement and return number of matches
|
||||
// replaced (maybe 0 if none found) or -1 on error
|
||||
|
@@ -315,6 +315,15 @@ bool wxRegEx::GetMatch(size_t *start, size_t *len, size_t index) const
|
||||
return m_impl->GetMatch(start, len, index);
|
||||
}
|
||||
|
||||
wxString wxRegEx::GetMatch(const wxString& text, size_t index) const
|
||||
{
|
||||
size_t start, len;
|
||||
if ( !GetMatch(&start, &len, index) )
|
||||
return wxEmptyString;
|
||||
|
||||
return text.Mid(start, len);
|
||||
}
|
||||
|
||||
int wxRegEx::Replace(wxString *pattern, const wxString& replacement) const
|
||||
{
|
||||
wxCHECK_MSG( IsValid(), -1, _T("must successfully Compile() first") );
|
||||
|
Reference in New Issue
Block a user