regexFind: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Some wiki formatting) |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 15: | Line 15: | ||
|p2= pattern: [[String]] - format [[Arma 3: Regular Expressions|regex pattern]] | |p2= pattern: [[String]] - format [[Arma 3: Regular Expressions|regex pattern]] | ||
|p3= offset: [[Number]] - (Optional, default: 0) has to be in range from 0 to | |p3= offset: [[Number]] - (Optional, default: 0) has to be in range from 0 to <sqf inline>count haystack</sqf> (haystack length) | ||
|r1= [[Array]] of nested arrays. Each lowest level array in format: | |r1= [[Array]] of nested arrays. Each lowest level array in format: | ||
Line 28: | Line 28: | ||
|x4= Multiline example: | |x4= Multiline example: | ||
<sqf>"co1kie2 | <sqf> | ||
"co1kie2 | |||
co2kie" regexFind ["^co.kie$"]; // [[["co2kie",9]]]</sqf> | co2kie" regexFind ["^co.kie$"]; // [[["co2kie",9]]]</sqf> | ||
|x5= <sqf>"I'm a cookie clicker" regexFind ["c(.*?)k(.*?)e/i"]; // [[["cookie",6], ["oo", 7], ["i", 10]]]</sqf> | |x5= <sqf>"I'm a cookie clicker" regexFind ["c(.*?)k(.*?)e/i"]; // [[["cookie",6], ["oo", 7], ["i", 10]]] | ||
</sqf> | |||
|x6= <sqf>"I'm a cookie clicker" regexFind ["c(.*?)k(.*?)e"]; // [[["cookie", 6], ["oo", 7], ["i", 10]], [["clicke", 13], ["lic", 14], ["", 18]]]</sqf> | |x6= <sqf>"I'm a cookie clicker" regexFind ["c(.*?)k(.*?)e"]; // [[["cookie", 6], ["oo", 7], ["i", 10]], [["clicke", 13], ["lic", 14], ["", 18]]]</sqf> |
Revision as of 15:43, 1 July 2022
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
- offset: Number - (Optional, default: 0) has to be in range from 0 to count haystack (haystack length)
- Return Value:
- Array of nested arrays. Each lowest level array in format:
Examples
- Example 1:
- 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