FindStrRegex
FindStrRegex( value, find, [start], [numResults] )
FindStrRegex( value, find, [start], [numResults] )
FindStrRegex( value, find, [start], [numResults] )
FindStrRegex( value, find, [start], [numResults] )
find_str_regex( value, find, [start], [numResults] )
FindStrRegex( value, find, [start], [numResults] )
Description
The FindStrRegex
function returns an array of up to 1,024 objects that
describe where the pattern is found in the search string.
Parameters
Parameter | Type | Definition and Requirements | ||
---|---|---|---|---|
|
The string to search in. |
|||
|
The Java-compatible regular expression pattern to find in the value string. |
|||
|
Optional - The offset into the search string in characters of where
the search should start. The default value, if omitted, is 0 code
points. The first position in the string is 0. If the value is less
than 0, then
|
|||
|
Optional - The number of matches to find in the search string. The default is 1,024 and the maximum is 1,024. |
Returns
An array of objects where each object contains the details of a match, including the start position, end position, and the sub-string that was matched.
Examples
-
The following query searches the string
ABC abc ABC
for the pattern[Bb]
, which matches the letterB
or the letterb
. The result is an array of the three matches that exist, with each match reporting the start and end positions of the match, and the actual sub-string that matched:Arr(ObjectV(start: LongV(1),end: LongV(1),data: StringV(B)), ObjectV(start: LongV(5),end: LongV(5),data: StringV(b)), ObjectV(start: LongV(9),end: LongV(9),data: StringV(B)))
[map[data:B end:1 start:1] map[data:b end:5 start:5] map[data:B end:9 start:9]]
[{start: 1, end: 1, data: "B"}, {start: 5, end: 5, data: "b"}, {start: 9, end: 9, data: "B"}]
[ { start: 1, end: 1, data: 'B' }, { start: 5, end: 5, data: 'b' }, { start: 9, end: 9, data: 'B' } ]
[{'start': 1, 'end': 1, 'data': 'B'}, {'start': 5, 'end': 5, 'data': 'b'}, {'start': 9, 'end': 9, 'data': 'B'}]
[ { start: 1, end: 1, data: 'B' }, { start: 5, end: 5, data: 'b' }, { start: 9, end: 9, data: 'B' } ]
-
The following query uses the same
value
string andfind
pattern as the previous example, but it also specifies astart
position. The start position is far enough into thevalue
string that there are only two matches in the result:Arr(ObjectV(start: LongV(5),end: LongV(5),data: StringV(b)), ObjectV(start: LongV(9),end: LongV(9),data: StringV(B)))
[map[data:b end:5 start:5] map[data:B end:9 start:9]]
[{start: 5, end: 5, data: "b"}, {start: 9, end: 9, data: "B"}]
[ { start: 5, end: 5, data: 'b' }, { start: 9, end: 9, data: 'B' } ]
[{'start': 5, 'end': 5, 'data': 'b'}, {'start': 9, 'end': 9, 'data': 'B'}]
[ { start: 5, end: 5, data: 'b' }, { start: 9, end: 9, data: 'B' } ]
-
The following query uses the same
value
string,find
pattern, andstart
position as the previous example, but it also specifies anumResults
limit. The limit restricts the number of results to one:Arr(ObjectV(start: LongV(5),end: LongV(5),data: StringV(b)))
[map[data:b end:5 start:5]]
[{start: 5, end: 5, data: "b"}]
[ { start: 5, end: 5, data: 'b' } ]
[{'start': 5, 'end': 5, 'data': 'b'}]
[ { start: 5, end: 5, data: 'b' } ]
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!