1
/***************************************************************
2
* Name: TextFileSearcherRegEx
3
* Purpose: TextFileSearcherRegEx is used to search text files
4
* for regular expressions.
5
* Author: Jerome ANTOINE
7
* Copyright: Jerome ANTOINE
9
**************************************************************/
13
// Required extra includes
14
#include <wx/string.h>
17
#include "TextFileSearcherRegEx.h"
20
TextFileSearcherRegEx::TextFileSearcherRegEx(const wxString& searchText, bool matchCase, bool matchWordBegin,
22
:TextFileSearcher(searchText, matchCase, matchWordBegin, matchWord)
24
wxString pattern = searchText;
26
#ifdef wxHAS_REGEX_ADVANCED
27
int flags = wxRE_ADVANCED;
29
int flags = wxRE_EXTENDED;
31
if ( matchCase == false )
36
if ( matchWord == true )
38
pattern = _T("([^[:alnum:]_]|^)") + pattern + _T("([^[:alnum:]_]|$)");
40
else if ( matchWordBegin == true )
42
pattern = _T("([^[:alnum:]_]|^)") + pattern;
45
m_RegEx.Compile(pattern, flags);
49
bool TextFileSearcherRegEx::MatchLine(wxString line)
52
if ( m_RegEx.IsValid() )
54
match = m_RegEx.Matches(line.c_str());
60
bool TextFileSearcherRegEx::IsOk(wxString* pErrorMessage)
62
bool ok = m_RegEx.IsValid();
63
if ( !ok && pErrorMessage )
65
*pErrorMessage = _T("Bad regular expression.");