Regex Matches

Extracts the matches found from a string when interrogated by a regex pattern.

Version 1

HTTP Request
POST /ado/v1/RegexMatches

Header

ParameterDescription
Ocp-Apim-Subscription-KeyThe subscription key you received when you purchased a plan.

Request Body

Mandatory

ParameterTypeDescription
patternstringThe regex pattern.
datastringThe string to execute the regex pattern over.

Common

Further Documentation: Common Parameters

ParameterTypeDescription
filterStringA fully functioning SQL based WHERE statement that will filter the outgoing dataset to the records it determines as being included.
sortOrderObjectSorts the resulting dataset by the criteria provided.
The object should contain property names that represent properties contained within the resulting dataset with a value corresponding to the desired sort direction (i.e. ASC or DESC).
schemaObjectYou can use this parameter to override the inferred schema for properties in the incoming dataset(s).
A field will be inferred unless specific explicitly within this object.
advancedOptionsObjectIs an object with the following properties.

cultureName (String)
The specified culture determines the behaviour for aspects related to formatting numeric values and dates. Is extremely important when converting strings to dates, e.g. 05/03/2022 will be treated differently between locales. For more information on the accepted values for this property, please consult the documentation from Microsoft … https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo?view=net-6.0#culture-names-and-identifiers

isBoolean (string[])
A list of strings that are the names of all properties in the resulting dataset that should be treated as boolean values.

By default, the framework treats boolean values as 1 (true) or 0 (false). In order to differentiate the integer as a boolean, the property in question needs to be called out explicitly in this list.

Notes

The regex pattern is able to be passed in as a base64 string or an encoded string that is accepted by JSON.

Different regex expressions will require various amounts of complexity when encoding but the framework does allow for both approaches which provides you with options when using this function.

Examples

Encoded Pattern
Base64 Pattern

This example extracts all email addresses found within the data string using the given pattern.

The pattern is encoded so as to work with the JSON structure.

Request

{
    "pattern": "((?>[a-zA-Z\\d!#$%&'*+\\-\\/=?^_`{|}~]+\\x20*|\"((?=[\\x01-\\x7f])[^\"\\\\]|\\\\[\\x01-\\x7f])*\"\\x20*)*(?<angle><))?((?!\\.)(?>\\.?[a-zA-Z\\d!#$%&'*+\\-\\/=?^_`{|}~]+)+|\"((?=[\\x01-\\x7f])[^\"\\\\]|\\\\[\\x01-\\x7f])*\")@(((?!-)[a-zA-Z\\d\\-]+(?<!-)\\.)+[a-zA-Z]{2,}|\\[(((?(?<!\\[)\\.)(25[0-5]|2[0-4]\\d|[01]?\\d?\\d)){4}|[a-zA-Z\\d\\-]*[a-zA-Z\\d]:((?=[\\x01-\\x7f])[^\\\\\\[\\]]|\\\\[\\x01-\\x7f])+)\\])(?(angle)>)",
    "data": "Let's extract email address someone@test.com and this email address test@somewhere.com."
}
Code language: JSON / JSON with Comments (json)

Response

[
    "someone@test.com",
    "test@somewhere.com"
]
Code language: JSON / JSON with Comments (json)

This example extracts all email addresses found within the data string using the given pattern.

The pattern is encoded as a base64 string.

Request

{
    "pattern": "KCg/PlthLXpBLVpcZCEjJCUmJyorXC1cLz0/Xl9ge3x9fl0rXHgyMCp8IigoPz1bXHgwMS1ceDdmXSlbXiJcXF18XFxbXHgwMS1ceDdmXSkqIlx4MjAqKSooPzxhbmdsZT48KSk/KCg/IVwuKSg/PlwuP1thLXpBLVpcZCEjJCUmJyorXC1cLz0/Xl9ge3x9fl0rKSt8IigoPz1bXHgwMS1ceDdmXSlbXiJcXF18XFxbXHgwMS1ceDdmXSkqIilAKCgoPyEtKVthLXpBLVpcZFwtXSsoPzwhLSlcLikrW2EtekEtWl17Mix9fFxbKCgoPyg/PCFcWylcLikoMjVbMC01XXwyWzAtNF1cZHxbMDFdP1xkP1xkKSl7NH18W2EtekEtWlxkXC1dKlthLXpBLVpcZF06KCg/PVtceDAxLVx4N2ZdKVteXFxcW1xdXXxcXFtceDAxLVx4N2ZdKSspXF0pKD8oYW5nbGUpPik=",
    "data": "Let's extract email address someone@test.com and this email address test@somewhere.com."
}
Code language: JSON / JSON with Comments (json)

Response

[
    "someone@test.com",
    "test@somewhere.com"
]
Code language: JSON / JSON with Comments (json)