regexFind: Difference between revisions
Jump to navigation
Jump to search
m (formatting) |
Lou Montana (talk | contribs) m (Text replacement - "↵↵</sqf>" to " </sqf>") |
||
(19 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{RV|type=command | {{RV|type=command | ||
|game1= | |game1= arma3 | ||
|version1= 2.06 | |||
| | |descr= Searches in a string with a regular expression. | ||
{{Feature|informative|See [[Arma 3: Regular Expressions]].}} | |||
| | |gr1= Strings - Regular Expression | ||
| | |s1= haystack [[regexFind]] [pattern, startOffset] | ||
| | |p1= haystack: [[String]] | ||
| | |p2= pattern: [[String]] - format [[Arma 3: Regular Expressions|regex pattern]] | ||
| | |||
| | |p3= startOffset: [[Number]] - (Optional, default 0) has to be in range from 0 to <sqf inline>count haystack</sqf> (''haystack''<nowiki/>'s length) | ||
| | |r1= [[Array]] of nested arrays. Each lowest level array in format: | ||
* 0: [[String]] - match | |||
* 1: [[Number]] - offset of given match relative to ''haystack'' beginning (the provided ''offset'' is ignored) | |||
|x1= < | |x1= <sqf>"wooKie boOkie cookie" regexFind [".ookie/gio"]; // [[["wooKie", 0]], [<nowiki/>["boOkie", 7]], [<nowiki/>["cookie", 14]]]</sqf> | ||
|x2= < | |x2= <sqf>"wooKie boOkie cookie" regexFind [".ookie/i"]; // [[["wooKie",0]]]</sqf> | ||
|x3= < | |x3= <sqf>"wooKie boOkie cookie" regexFind [".ookie/"]; // [[["cookie", 14]]]</sqf> | ||
|x4= Multiline example:< | |x4= Multiline example: | ||
co2kie" | <sqf> | ||
"co1kie2 | |||
co2kie" regexFind ["^co.kie$"]; // [[["co2kie",9]]]</sqf> | |||
|x5= < | |x5= <sqf> | ||
"I'm a cookie clicker" regexFind ["c(.*?)k(.*?)e/i"]; // [[["cookie",6], ["oo", 7], ["i", 10]]] | |||
</sqf> | |||
|x6= < | |x6= <sqf>"I'm a cookie clicker" regexFind ["c(.*?)k(.*?)e"]; // [[["cookie", 6], ["oo", 7], ["i", 10]], [["clicke", 13], ["lic", 14], ["", 18]]]</sqf> | ||
|seealso= [[regexMatch]] [[regexReplace]] | |seealso= [[regexMatch]] [[regexReplace]] | ||
}} | }} |
Latest revision as of 19:48, 3 September 2024
Description
- Description:
- Searches in a string with a regular expression.
- Groups:
- Strings - Regular Expression
Syntax
- Syntax:
- haystack regexFind [pattern, startOffset]
- Parameters:
- haystack: String
- pattern: String - format regex pattern
- startOffset: Number - (Optional, default 0) has to be in range from 0 to count haystack (haystack's length)
- Return Value:
- Array of nested arrays. Each lowest level array in format:
Examples
- Example 1:
- "wooKie boOkie cookie" regexFind [".ookie/gio"]; // [[["wooKie", 0]], [["boOkie", 7]], [["cookie", 14]]]
- Example 2:
- "wooKie boOkie cookie" regexFind [".ookie/i"]; // [[["wooKie",0]]]
- Example 3:
- "wooKie boOkie cookie" regexFind [".ookie/"]; // [[["cookie", 14]]]
- Example 4:
- Multiline example:
"co1kie2 co2kie" regexFind ["^co.kie$"]; // [[["co2kie",9]]]
- Example 5:
- "I'm a cookie clicker" regexFind ["c(.*?)k(.*?)e/i"]; // [[["cookie",6], ["oo", 7], ["i", 10]]]
- Example 6:
- "I'm a cookie clicker" regexFind ["c(.*?)k(.*?)e"]; // [[["cookie", 6], ["oo", 7], ["i", 10]], [["clicke", 13], ["lic", 14], ["", 18]]]
Additional Information
- See also:
- regexMatch regexReplace
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note