From 83570e6e7e0bde1131bdeca0cd86923d7b002bc2 Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Sun, 1 May 2016 11:35:10 -0400 Subject: [PATCH 1/2] Add regular expression functions --- Mod Sources/TSExtension/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Mod Sources/TSExtension/README.md b/Mod Sources/TSExtension/README.md index 3fbe00d..90d7da2 100644 --- a/Mod Sources/TSExtension/README.md +++ b/Mod Sources/TSExtension/README.md @@ -23,3 +23,33 @@ This function did not exist before in Torque Script. It returns a formatted stri arguments up to a total of twenty filled in. Refer to C's sprintf for more information. Note: Only %s should be used in the format as Torque Script passes all data around as strings. + +#### reSearch(pattern, target) +Searches for the occurrences of a regular expression pattern within the target text. + +Ex: echo(reSearch("[0-9]+", "ABC123DEF")); + +#### reMatch(pattern, target) +Attempts to match the entire target string to the input regular expression pattern. + +Ex: echo(reMatch("[A-z]+", "ABC")); + +#### reReplace(pattern, target, replace) +Replaces the regular expression pattern within the target text with some given replace text. + +Ex: echo(reReplace("[0-9]", "123|456|789|12345678111111", "*")); + +#### reIterBegin(pattern, target) +Begins a regular expression iterator through the target string, matching the input regular expression pattern. Use reIterNext to find all matching patterns and reIterEnd to determine if the iterator has ended. + +Ex: echo(reIterBegin("[A-z]+\\|", "ONE|TWO|THREE|FOUR|FIVE")); + +#### reIterNext() +Returns the next matching pattern in the input text specified in reIterBegin. + +Ex: %match = reIterNext(); + +#### reIterEnd() +Returns true when the regular expression iterator has ended. + +Ex: while(!reIterEnd()) From f7217e767f4756a5f705d15dfe1ca26e31943e23 Mon Sep 17 00:00:00 2001 From: Robert MacGregor Date: Sun, 1 May 2016 11:35:34 -0400 Subject: [PATCH 2/2] Minor regex fix --- Mod Sources/TSExtension/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mod Sources/TSExtension/README.md b/Mod Sources/TSExtension/README.md index 90d7da2..812b799 100644 --- a/Mod Sources/TSExtension/README.md +++ b/Mod Sources/TSExtension/README.md @@ -42,7 +42,7 @@ Ex: echo(reReplace("[0-9]", "123|456|789|12345678111111", "*")); #### reIterBegin(pattern, target) Begins a regular expression iterator through the target string, matching the input regular expression pattern. Use reIterNext to find all matching patterns and reIterEnd to determine if the iterator has ended. -Ex: echo(reIterBegin("[A-z]+\\|", "ONE|TWO|THREE|FOUR|FIVE")); +Ex: echo(reIterBegin("[A-z]+\\|?", "ONE|TWO|THREE|FOUR|FIVE")); #### reIterNext() Returns the next matching pattern in the input text specified in reIterBegin.