FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date. Fauna accounts created after August 21, 2024 must use FQL v10. These accounts will not be able to run FQL v4 queries or access the v4 Dashboard. For more details, see the v4 EOL announcement and migration guide. Contact support@fauna.com with any questions. |
FindStrRegex
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
FindStrRegex( value, find, [start], [numResults] )
find_str_regex( value, find, [start], [numResults] )
FindStrRegex( value, find, [start], [numResults] )
FindStrRegex( value, find, [start], [numResults] )
FindStrRegex( 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 | ||
---|---|---|---|---|
|
String |
The string to search in. |
||
|
String |
The Java-compatible regular expression pattern to find in the value string. |
||
|
Integer |
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
|
||
|
Integer |
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:[ { 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'}]
[map[data:B end:1 start:1] map[data:b end:5 start:5] map[data:B end:9 start:9]]
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)))
[{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:[ { start: 5, end: 5, data: 'b' }, { start: 9, end: 9, data: 'B' } ]
[{'start': 5, 'end': 5, 'data': 'b'}, {'start': 9, 'end': 9, 'data': 'B'}]
[map[data:b end:5 start:5] map[data:B end:9 start:9]]
Arr(ObjectV(start: LongV(5),end: LongV(5),data: StringV(b)), ObjectV(start: LongV(9),end: LongV(9),data: StringV(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:[ { start: 5, end: 5, data: 'b' } ]
[{'start': 5, 'end': 5, 'data': 'b'}]
[map[data:b end:5 start:5]]
Arr(ObjectV(start: LongV(5),end: LongV(5),data: StringV(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!