Browse Source

Merge pull request #2727 from Ovnuniarchos/DocRegex

RegEx class documented.
Rémi Verschelde 9 years ago
parent
commit
7675a3b535
1 changed files with 31 additions and 1 deletions
  1. 31 1
      doc/base/classes.xml

+ 31 - 1
doc/base/classes.xml

@@ -26656,7 +26656,7 @@
 	Reference frame for GUI.
 	Reference frame for GUI.
 	</brief_description>
 	</brief_description>
 	<description>
 	<description>
-	Reference frame for GUI. It's just like an empty control, except a red box is displayed while editing around it's size at all times.
+	Reference frame for GUI. It's just like an empty control, except a red box is displayed while editing around its size at all times.
 	</description>
 	</description>
 	<methods>
 	<methods>
 	</methods>
 	</methods>
@@ -26669,58 +26669,88 @@
 </class>
 </class>
 <class name="RegEx" inherits="Reference" category="Core">
 <class name="RegEx" inherits="Reference" category="Core">
 	<brief_description>
 	<brief_description>
+	Simple regular expression matcher.
 	</brief_description>
 	</brief_description>
 	<description>
 	<description>
+	Class for finding text patterns in a string using regular expressions. Regular expressions are a way to define patterns of text to be searched.
+	This class only finds patterns in a string. It can not perform replacements.
+	Usage of regular expressions is too long to be explained here, but Internet is full of tutorials and detailed explanations.
+	Currently supported features:
+		Capturing [code]()[/code] and non-capturing [code](?:)[/code] groups
+		Any character [code].[/code]
+		Shorthand caracter classes [code]\w \W \s \S \d \D[/code]
+		User-defined character classes such as [code][A-Za-z][/code]
+		Simple quantifiers [code]?[/code], [code]*[/code] and [code]+[/code]
+		Range quantifiers [code]{x,y}[/code]
+		Lazy (non-greedy) quantifiers [code]*?[/code]
+		Begining [code]^[/code] and end [code]$[/code] anchors
+		Alternation [code]|[/code]
+		Backreferences [code]\1[/code] to [code]\99[/code]
 	</description>
 	</description>
 	<methods>
 	<methods>
 		<method name="compile">
 		<method name="compile">
 			<return type="int">
 			<return type="int">
+			[OK] if the regular expression was valid. [FAIL] otherwise.
 			</return>
 			</return>
 			<argument index="0" name="pattern" type="String">
 			<argument index="0" name="pattern" type="String">
+			The string to be converted into a regular expression.
 			</argument>
 			</argument>
 			<description>
 			<description>
+			Once created, a RegEx object needs a regular expression to be assigned to it. This method tries to convert the string given to an usable regular expression.
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="find" qualifiers="const">
 		<method name="find" qualifiers="const">
 			<return type="int">
 			<return type="int">
+			The position within the string (starting with 0) where the pattern was found. It will return -1 if the pattern was not found, it was invalid, or the start or end positions were beyond the string's end.
 			</return>
 			</return>
 			<argument index="0" name="text" type="String">
 			<argument index="0" name="text" type="String">
+			The text to search the pattern in.
 			</argument>
 			</argument>
 			<argument index="1" name="start" type="int" default="0">
 			<argument index="1" name="start" type="int" default="0">
+			The position in the string (starting with 0) to start searching from.
 			</argument>
 			</argument>
 			<argument index="2" name="end" type="int" default="-1">
 			<argument index="2" name="end" type="int" default="-1">
+			The position in the string (starting with 0) to stop searching. A value less than the start position means "end of the string".
 			</argument>
 			</argument>
 			<description>
 			<description>
+			This method tries to find the pattern within the string, and returns the position where it was found. It also stores any capturing group (see [method get_capture]) for further retrieval.
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="clear">
 		<method name="clear">
 			<description>
 			<description>
+			This method resets the state of the object, as it was freshly created. Namely, it unassigns the regular expression of this object, and forgets all captures made by the last [method find].
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="is_valid" qualifiers="const">
 		<method name="is_valid" qualifiers="const">
 			<return type="bool">
 			<return type="bool">
 			</return>
 			</return>
 			<description>
 			<description>
+			Returns whether this object has a valid regular expression assigned.
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="get_capture_count" qualifiers="const">
 		<method name="get_capture_count" qualifiers="const">
 			<return type="int">
 			<return type="int">
 			</return>
 			</return>
 			<description>
 			<description>
+			Returns the number of capturing groups. A captured group is the part of a string that matches a part of the pattern delimited by parentheses (unless they are non-capturing parentheses [i](?:)[/i]).
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="get_capture" qualifiers="const">
 		<method name="get_capture" qualifiers="const">
 			<return type="String">
 			<return type="String">
 			</return>
 			</return>
 			<argument index="0" name="capture" type="int">
 			<argument index="0" name="capture" type="int">
+			The number of the captured group, starting with 0. Like other regular expression engines, Godot's engine takes 0 as the full expression, and 1 as the first pair of capturing parentheses.
 			</argument>
 			</argument>
 			<description>
 			<description>
+			Returns a captured group. A captured group is the part of a string that matches a part of the pattern delimited by parentheses (unless they are non-capturing parentheses [i](?:)[/i]).
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="get_captures" qualifiers="const">
 		<method name="get_captures" qualifiers="const">
 			<return type="StringArray">
 			<return type="StringArray">
+			A list contining all the strings captured by the regular expression.
 			</return>
 			</return>
 			<description>
 			<description>
+			Return a list of all the captures made by the regular expression.
 			</description>
 			</description>
 		</method>
 		</method>
 	</methods>
 	</methods>