Difference between revisions of "regexFind"

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Fixed "regex pattern" link)
m (Fixed repeated word)
Line 4: Line 4:
|version1= 2.06
|version1= 2.06
|descr= Returns all all matches found with given ''pattern'' in given ''haystack'' and their offset.
|descr= Returns all matches found with given ''pattern'' in given ''haystack'' and their offset.
|gr1= Strings - Regular Expression
|gr1= Strings - Regular Expression

Revision as of 20:05, 5 November 2021

Hover & click on the images for description


Returns all matches found with given pattern in given haystack and their offset.
Strings - Regular Expression


haystack regexFind [pattern, startOffset]
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:
  • 0: String - Match
  • 1: Number - Offset of given match relative to haystack beginning. Provided offset is ignored


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


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