27 #include <boost/regex.hpp>
28 using namespace boost;
58 delete (wregex*)_handle;
63 const wchar_t* _pattern,
size_t _n,
67 wregex::flag_type flags = wregex::extended;
69 flags |= wregex::icase;
71 flags |= wregex::nosubs;
74 flags |= wregex::newline_alt;
77 ((wregex*)_handle)->assign(_pattern, _pattern + _n, flags);
89 const wchar_t* _begin,
const wchar_t* _end,
93 regex_constants::match_flag_type flags = regex_constants::match_default;
95 flags |= regex_constants::match_not_bol;
97 flags |= regex_constants::match_not_eol;
101 bool b = regex_match(_begin, _end, m, *((
const wregex*)_handle), flags);
106 for(
size_t i = 0; i < m.size(); i++)
108 match[i].
first = m[i].first;
109 match[i].
second = m[i].second;
110 match[i].
matched = m[i].matched;
121 const wchar_t* _begin,
const wchar_t* _end,
125 regex_constants::match_flag_type flags = regex_constants::match_default;
127 flags |= regex_constants::match_not_bol;
129 flags |= regex_constants::match_not_eol;
132 bool r = regex_match(_begin, _end, *(
const wregex*)_handle, flags);
139 const wchar_t* _begin,
const wchar_t* _end,
143 regex_constants::match_flag_type flags = regex_constants::match_default;
145 flags |= regex_constants::match_not_bol;
147 flags |= regex_constants::match_not_eol;
151 bool r = regex_search(_begin, _end, m, *((
const wregex*)_handle), flags);
156 for(
size_t i = 0; i < m.size(); i++)
158 match[i].
first = m[i].first;
159 match[i].
second = m[i].second;
160 match[i].
matched = m[i].matched;
171 const wchar_t* _begin,
const wchar_t* _end,
175 regex_constants::match_flag_type flags = regex_constants::match_default;
177 flags |= regex_constants::match_not_bol;
179 flags |= regex_constants::match_not_eol;
182 bool r = regex_search(_begin, _end, *(
const wregex*)_handle, flags);
188 const wchar_t* _regex,
const wchar_t* _regexend,
189 const wchar_t* _begin,
const wchar_t* _end,
193 regex::flag_type flags = regex::ECMAScript;
195 flags |= regex::icase;
200 wregex re(_regex, _regexend, flags);
202 bool r = regex_match(_begin, _end, re);
207 catch (std::exception& e) {
213 const char* _regex,
const char* _regexend,
214 const char* _begin,
const char* _end,
218 regex::flag_type flags = regex::ECMAScript;
220 flags |= regex::icase;
225 regex re(_regex, _regexend, flags);
227 bool r = regex_match(_begin, _end, re);
232 catch (std::exception& e) {
238 const wchar_t* _regex,
const wchar_t* _regexend,
239 const wchar_t* _begin,
const wchar_t* _end,
245 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
247 flags |= regex::icase;
250 size_t r = (size_t)-1;
253 wregex re(_regex, _regexend, flags);
257 if (regex_search(_begin, _end, m, re)) {
258 r = m[0].first - _begin;
263 catch (std::exception& e) {
270 const char* _regex,
const char* _regexend,
271 const char* _begin,
const char* _end,
277 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
279 flags |= regex::icase;
282 size_t r = (size_t)-1;
285 regex re(_regex, _regexend, flags);
290 if (regex_search(_begin, _end, m, re)) {
291 r = m[0].first - _begin;
296 catch (std::exception& e) {
303 const wchar_t* _regex,
const wchar_t* _regexend,
304 const wchar_t* _begin,
const wchar_t* _end,
310 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
312 flags |= regex::icase;
318 wregex re(_regex, _regexend, flags);
322 if (regex_search(_begin, _end, m, re)) {
323 r.assign(m[0].first, m[0].second);
328 catch (std::exception& e) {
335 const char* _regex,
const char* _regexend,
336 const char* _begin,
const char* _end,
342 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
344 flags |= regex::icase;
350 regex re(_regex, _regexend, flags);
355 if (regex_search(_begin, _end, m, re)) {
356 r.assign(m[0].first, m[0].second);
361 catch (std::exception& e) {
368 const wchar_t* _regex,
const wchar_t* _regexend,
369 const wchar_t* _begin,
const wchar_t* _end,
370 const wchar_t* _replacement,
const wchar_t* _replacementend,
375 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
377 flags |= regex::icase;
383 wregex re(_regex, _regexend, flags);
387 while (_begin < _end && _limit && regex_search(_begin, _end, m, re)) {
389 r.append(_begin, m[0].first)
390 .append(_replacement, _replacementend);
393 _begin = m[0].second;
397 r.append(_begin, _end);
403 catch (std::exception& e) {
409 const char* _regex,
const char* _regexend,
410 const char* _begin,
const char* _end,
411 const char* _replacement,
const char* _replacementend,
416 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
418 flags |= regex::icase;
424 regex re(_regex, _regexend, flags);
428 while (_begin < _end && _limit && regex_search(_begin, _end, m, re)) {
430 r.append(_begin, m[0].first)
431 .append(_replacement, _replacementend);
434 _begin = m[0].second;
438 r.append(_begin, _end);
444 catch (std::exception& e) {
450 const wchar_t* _regex,
const wchar_t* _regexend,
451 const wchar_t* _begin,
const wchar_t* _end,
453 StringArray& _results,
457 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
459 flags |= regex::icase;
464 wregex re(_regex, _regexend, flags);
468 while (_begin < _end && _limit && regex_search(_begin, _end, m, re)) {
470 _results.add(String(_begin, m[0].first));
473 _begin = m[0].second;
477 _results.add(String(_begin, _end));
483 catch (std::exception& e) {
489 const char* _regex,
const char* _regexend,
490 const char* _begin,
const char* _end,
492 ByteStringArray& _results,
496 regex::flag_type flags = regex::ECMAScript | regex::nosubs;
498 flags |= regex::icase;
503 regex re(_regex, _regexend, flags);
507 while (_begin < _end && _limit && regex_search(_begin, _end, m, re)) {
509 _results.add(ByteString(_begin, m[0].first));
512 _begin = m[0].second;
516 _results.add(ByteString(_begin, _end));
522 catch (std::exception& e) {
bool __regex_search(regex_handle _handle, const wchar_t *_begin, const wchar_t *_end, match_result **_results, unsigned int _flags)
void __matches_free(match_result *_results)
String __regex_substring(const wchar_t *_regex, const wchar_t *_regexend, const wchar_t *_begin, const wchar_t *_end, bool _icase) __DCL_THROWS1(RegexException *)
StringArray & __regex_split(const wchar_t *_regex, const wchar_t *_regexend, const wchar_t *_begin, const wchar_t *_end, bool _icase, StringArray &_results, size_t _limit) __DCL_THROWS1(RegexException *)
size_t __regex_match(regex_handle _handle, const wchar_t *_begin, const wchar_t *_end, match_result **_results, unsigned int _flags)
String __regex_replace(const wchar_t *_regex, const wchar_t *_regexend, const wchar_t *_begin, const wchar_t *_end, const wchar_t *_replacement, const wchar_t *_replacementend, bool _icase, size_t _limit) __DCL_THROWS1(RegexException *)
__DCL_BEGIN_NAMESPACE regex_handle __regex_create()
bool __regex_matches(const wchar_t *_regex, const wchar_t *_regexend, const wchar_t *_begin, const wchar_t *_end, bool _icase) __DCL_THROWS1(RegexException *)
void __regex_compile(regex_handle _handle, const wchar_t *_pattern, size_t _n, unsigned int _flags)
void __regex_destroy(regex_handle _handle)
#define __DCL_DEBUG_ALLOC_LEAVE
#define __DCL_ASSERT(expr)
#define __DCL_DEBUG_ALLOC_ENTER