regexFind: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Article creation)
 
m (formatting)
Line 5: Line 5:
|version1= 2.05
|version1= 2.05


|descr= Offsets are relative to haystack start, ignoring the provided startOffset.
|descr= Offsets are relative to haystack start, ignoring the provided startOffset. startOffset being <0 or >= count hayStack will trigger a script error and return empty array
startOffset being <0 or >= count hayStack will trigger a script error and return empty array


|gr1= regex
|gr1= Regular Expression (Regex)


|s1= haystack [[{{PAGENAMEE}}]] [pattern, (startOffset)]
|s1= haystack [[{{PAGENAMEE}}]] [pattern, startOffset]


|r1= [[match1, offset1], [match2, offset2], ... [matchN, offsetN]]
|r1= [[match1, offset1], [match2, offset2], ... [matchN, offsetN]]
Line 16: Line 15:
|p1= haystack: [[String]]
|p1= haystack: [[String]]


|p2= pattern: [[String]] - Format [[:Category:Command Group: regex|regex pattern]]
|p2= pattern: [[String]] - Format [[:Category:Command Group: Regular Expression (Regex)|regex pattern]]


|p3= offset: [[Number]] - (Optional) default: 0, must be count haystack < offset >= 0
|p3= offset: [[Number]] - (Optional, default: 0) The ''offset has to be smaller then {{ic|[[count]] ''haystack''}} and {{ic|>= 0}}


|x1= <code>"wooKie boOkie cookie" [[{{PAGENAMEE}}]] [".ookie/gio"] {{cc|<nowiki>[["wooKie",0],["boOkie",7],["cookie",14]]</nowiki>}}</code>
|x1= <code>"wooKie boOkie cookie" [[{{PAGENAMEE}}]] [".ookie/gio"] {{cc|<nowiki>[["wooKie",0],["boOkie",7],["cookie",14]]</nowiki>}}</code>

Revision as of 08:28, 25 April 2021

-wrong parameter ("arma3dev") defined!-[[:Category:Introduced with arma3dev version 2.05|2.05]]
Hover & click on the images for description

Description

Description:
Offsets are relative to haystack start, ignoring the provided startOffset. startOffset being <0 or >= count hayStack will trigger a script error and return empty array
Groups:
Regular Expression (Regex)

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 -No code provided-
Return Value:
[[match1, offset1], [match2, offset2], ... [matchN, offsetN]]

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

[[Category:Introduced with arma3dev version 2.05]][[ Category: arma3dev: New Scripting Commands | REGEXFIND]][[ Category: arma3dev: Scripting Commands | REGEXFIND]]