virtualx-engine/drivers/nrex/regex.h
Zher Huei Lee d0ddf150d9 updated the RegEx library nrex to v0.1
After implementing unit testing to nrex I caught and fixed some errors
so it should behave more like Python's RegEx In addition, I've added
version numbering so it should be able to tell if the library needs
updating. Here are a list of changes:

- Fixed zero count quantifiers failing.
- Fixed infinite recursion if quantifying zero length token.
- Fixed `$` (as a string pattern on its own) not matching.
- Fixed look behind rewinding beyond the start of the string.
- Added support for alternative back reference format `\g{1}` similar to
Python. This allows digits to be used immediately after back references.
- Number of capture groups are still limited to 9 by default but can now
be manually set, with option for no limit at all. (Python has no limit)
- Curly bracket quantifiers `{0}` no longer interpreted as a literal
string if previous token is not quantifiable. (Python behaviour)
2015-12-04 21:18:41 +00:00

47 lines
1.2 KiB
C++

/*************************************************/
/* regex.h */
/*************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/*************************************************/
/* Source code within this file is: */
/* (c) 2007-2010 Juan Linietsky, Ariel Manzur */
/* All Rights Reserved. */
/*************************************************/
#ifndef REGEX_H
#define REGEX_H
#include "ustring.h"
#include "vector.h"
#include "core/reference.h"
#include "nrex.hpp"
class RegEx : public Reference {
OBJ_TYPE(RegEx, Reference);
mutable String text;
mutable Vector<nrex_result> captures;
nrex exp;
protected:
static void _bind_methods();
StringArray _bind_get_captures() const;
public:
void clear();
bool is_valid() const;
int get_capture_count() const;
String get_capture(int capture) const;
Error compile(const String& p_pattern, int capture = 9);
int find(const String& p_text, int p_start = 0, int p_end = -1) const;
RegEx();
RegEx(const String& p_pattern);
~RegEx();
};
#endif // REGEX_H