String patterns

You can use the built-in string patterns for text extraction and matching.

Common patterns

Table 1. Common patterns
Pattern Description Example
pattern for a number Matches Java™-style double values. set decision to "Number: 123!" extracting the first string matching the pattern for a number

Expected output: "123"

pattern for a number using locale <string> Matches a number that is formatted by using the given locale. set decision to "Prix: 999,99 euros" extracting the first string matching the pattern for a number using locale "fr-FR"

Expected output: "999,99"

pattern for a number using <string> Matches a number by using a string format. The locale is "en-US". set decision to "Prix: 999,99 euros" extracting the first string matching the pattern for a number using "##,#;(#)"

Expected output: "999,99"

pattern for a number using locale <string> and <string> Matches a number by using both locale and string format. set decision to "Solde: (999,99) euros" extracting the first string matching the pattern for a number using locale "fr-FR" and "##,#;(#)"

Expected output: "(999,99)"

pattern for a boolean Matches Java Boolean values. set decision to "b = true;" extracting the first string matching the pattern for a boolean

Expected output: "true"

Date and time patterns

Table 2. Date and time patterns
Pattern Description Example

pattern for a date

pattern for a date & time

pattern for a universal date & time

pattern for a time

Matches ISO format for date, date & time, universal date & time, or time. set decision to "Date: 2025-02-14" extracting the first string matching the pattern for a date

Expected output: "2025-02-14"

pattern for a date using locale <string>

pattern for a date & time using locale <string>

pattern for a universal date & time using locale <string>

pattern for a time using locale <string>

Matches ISO format for date, date & time, universal date & time, or time, by using the specified locale. set decision to "Date: 2025-02-14" extracting the first string matching the pattern for a date & time using locale "fr-FR"

Expected output: "2025-02-14"

pattern for a date using <string>

pattern for a date & time using <string>

pattern for a universal date & time using <string>

pattern for a time using <string>

Matches date, date & time, universal date & time, or time by using the specified string format. The locale is "en-US". set decision to "Date: 2/14/25" extracting the first string matching the pattern for a date using "M/d/yy";

Expected output: "2/14/25"

pattern for a date using locale <string> and <string>

pattern for a date & time using locale <string> and <string>

pattern for a universal date & time using locale <string> and <string>

pattern for a time using locale <string> and <string>

Matches date, date & time, universal date & time, or time by using both locale and string format. set decision to "Date: 2/14/25" extracting the first string matching the pattern for a date using locale "en-US" and "M/d/yy";

Expected output: "2/14/25"

Email and URL matching patterns

Table 3. Email and URL matching patterns
Pattern Description Example
pattern for an email Matches email addresses. set decision to "His e-mail is john@example.com." extracting the first string matching the pattern for an email;

Expected output: "john@example.com"

pattern for a URL Matches URLs (with or without protocol) and IP addresses. set decision to "The link to our site is ibm.com." extracting the first string matching the pattern for a URL;

Expected output: "ibm.com"

Plain text matching patterns

Table 4. Plain text matching patterns
Pattern Description Example

pattern for space separators

pattern for optional space separators

Matches multiple or optional space separator characters. set decision to "A\n\tB \n C" divided into parts by the pattern for space separators

Expected output: { "A", "B", "C" }

set decision to "A,B, C" divided into parts by "," + the pattern for optional space separators

Expected output: { "A", "B", "C" }

pattern for a text line Matches each line excluding end-of-line characters. set decision to "ABC\n\nD\n" extracting all strings matching the pattern for a text line

Expected output: { "ABC", "", "D" }

pattern for a text line containing <string>

pattern for a text line not containing <string>

pattern for a text line containing the phrase corresponding to <string>

pattern for a text line not containing the phrase corresponding to <string>

Matches lines containing (or not containing) the string or phrase. Phrase variants match whole words. set decision to "AB\nBC\nCD\nDE" extracting all strings matching the pattern for a text line containing "C"

Expected output: { "BC", "CD" }

set decision to "AB\nBC\nCD\nDE" extracting all strings matching the pattern for a text line not containing "C"

Expected output:{ "AB", "DE" }

pattern for the text before <string>

pattern for the text before the last occurrence of <string>

pattern for the word-delimited text before <string>

pattern for the word-delimited text before the last occurrence of <string>

Matches text before a string. Word-delimited variants match whole words. set decision to "A or B or C" extracting the first string matching the pattern for the text before " or "

Expected output:"A"

set decision to "A or B or C" extracting the first string matching the pattern for the text before the last occurrence of " or "

Expected output:"A or B"

pattern for the text after <string>

pattern for the text after the last occurrence of <string>

pattern for the word-delimited text after <string>

pattern for the word-delimited text after the last occurrence of <string>

Matches text after a string. Word-delimited variants match whole words. set decision to "A or B or C" extracting the first string matching the pattern for the text after " or "

Expected output:"B or C"

set decision to "A or B or C" extracting the first string matching the pattern for the text after the last occurrence of " or "

Expected output: "C"

pattern for the text after <string> and before <string>

pattern for the text after <string> and before the last occurrence of <string>

pattern for the word-delimited text after <string> and before <string>

pattern for the word-delimited text after <string> and before the last occurrence of <string>

Matches text between two strings. Word-delimited variants match whole words. set decision to "John ran 10 miles, Peter ran 12 miles" extracting all strings matching the pattern for the text after "ran" and before "miles"

Expected output:{ " 10 ", " 12 " }

set decision to "json: { \"a\": { \"b\": 123 } }" extracting the first string matching the pattern for the text after "{" and before the last occurrence of "}"

Expected output:" \"a\": { \"b\": 123 } "

set decision to "<doc><value type='int'>123</value><tag/></doc>" extracting the first string matching the pattern for the text after ">" and before the last occurrence of "</"

Expected output:"<value type='int'>123</value><tag/>"

set decision to "makeup make retake make take mistakes" extracting the first string matching the pattern for the word-delimited text after "make" and before the last occurrence of "take"

Expected output:" retake make "

CSV patterns

Table 5. CSV patterns
Pattern Description Example
pattern for a CSV value Matches values between commas in a CSV string. set decision to "1997,Ford,,E350,\"Super, \"\"luxurious\"\" truck" extracting all strings matching the pattern for a CSV value

Expected output: { "1997", "Ford", "", "E350", "\"Super, \"\"luxurious\"\" truck" }

pattern for a CSV separator Matches the separators in a CSV string. set decision to "1997,Ford,,E350,\"Super, \"\"luxurious\"\" truck" divided into parts by the pattern for a CSV separator;

Expected output: { "1997", "Ford", "", "E350", "\"Super, \"\"luxurious\"\" truck" }

Markdown patterns

Table 6. Markdown patterns
Pattern Description Example
pattern for a markdown code block Matches text of a markdown-style code block. set decision to "Code:\n `\n A + B\n `" extracting all strings matching the pattern for a markdown code block;

Expected output: { "```\n A + B\n ```" }

set decision to "Code:\n `\nA + B\n `" extracting all strings matching the pattern for a markdown code block;

Expected output: { }