summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Murgia - StraToN <the.straton@gmail.com>2016-02-12 07:45:12 +0100
committerJulian Murgia - StraToN <the.straton@gmail.com>2016-02-12 07:45:12 +0100
commite380ea8faca1ea9bbd3338a47ebc81ac01acc9bc (patch)
tree2fb9a2f0a55ba1ce68d411b8fb18fb34ae418465
parent334b3bc9b01fc0a17525e899400b3323e5caa02f (diff)
Added RegEx::get_capture_start() method
-rw-r--r--drivers/nrex/regex.cpp9
-rw-r--r--drivers/nrex/regex.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/drivers/nrex/regex.cpp b/drivers/nrex/regex.cpp
index 459cf28e1e..223e521725 100644
--- a/drivers/nrex/regex.cpp
+++ b/drivers/nrex/regex.cpp
@@ -21,6 +21,7 @@ void RegEx::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_valid"),&RegEx::is_valid);
ObjectTypeDB::bind_method(_MD("get_capture_count"),&RegEx::get_capture_count);
ObjectTypeDB::bind_method(_MD("get_capture","capture"),&RegEx::get_capture);
+ ObjectTypeDB::bind_method(_MD("get_capture_start","capture"),&RegEx::get_capture_start);
ObjectTypeDB::bind_method(_MD("get_captures"),&RegEx::_bind_get_captures);
};
@@ -68,6 +69,14 @@ String RegEx::get_capture(int capture) const {
}
+int RegEx::get_capture_start(int capture) const {
+
+ ERR_FAIL_COND_V( get_capture_count() <= capture, String() );
+
+ return captures[capture].start;
+
+}
+
Error RegEx::compile(const String& p_pattern, int capture) {
clear();
diff --git a/drivers/nrex/regex.h b/drivers/nrex/regex.h
index ae8d40ceab..4b063f0bf1 100644
--- a/drivers/nrex/regex.h
+++ b/drivers/nrex/regex.h
@@ -35,6 +35,7 @@ public:
void clear();
bool is_valid() const;
int get_capture_count() const;
+ int get_capture_start(int capture) 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;