Difference between revisions of "regexFind"

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " |descr=" to " |branch= dev |descr=")
m (Text replacement - "Regular Expression (Regex)" to "Strings - Regular Expression")
Line 8: Line 8:
 
|descr= Returns all all matches found with given ''pattern'' in given ''haystack'' and their offset.
 
|descr= Returns all all matches found with given ''pattern'' in given ''haystack'' and their offset.
  
|gr1= Regular Expression (Regex)
+
|gr1= Strings - Regular Expression
  
 
|s1= haystack [[{{PAGENAMEE}}]] [pattern, startOffset]
 
|s1= haystack [[{{PAGENAMEE}}]] [pattern, startOffset]
Line 14: Line 14:
 
|p1= haystack: [[String]]
 
|p1= haystack: [[String]]
  
|p2= pattern: [[String]] - Format [[:Category:Command Group: Regular Expression (Regex)|regex pattern]]
+
|p2= pattern: [[String]] - Format [[:Category:Command Group: Strings - Regular Expression|regex pattern]]
  
 
|p3= offset: [[Number]] - (Optional, default: 0) The ''offset'' has to be smaller then {{ic|[[count]] haystack}} and {{ic|>{{=}} 0}}
 
|p3= offset: [[Number]] - (Optional, default: 0) The ''offset'' has to be smaller then {{ic|[[count]] haystack}} and {{ic|>{{=}} 0}}

Revision as of 17:42, 13 July 2021

Hover & click on the images for description
Only available in Development branch(es) until its release with Arma 3 patch v2.06.

Description

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

Syntax

Syntax:
haystack regexFind [pattern, startOffset]
Parameters:
haystack: String
pattern: String - Format regex pattern
offset: Number - (Optional, default: 0) The offset has to be smaller then count haystack and >= 0
Return Value:
Array of arrays. Each array in format:
  • 0: String - Match
  • 1: Number - Offset of given match relative to haystack beginning. Provided offset is ignored

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/"]; // [["wooKie",0],["boOkie",7],["cookie",14]]
Example 4:
Multiline example:"co1kie2 co2kie" regexFind ["^co.kie$"]; // [["co1kie",0],["co2kie",8]]
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