Skip to content

bmel:matches-pattern

Category: String · Returns: bmel:boolean

Signature
bmel:matches-pattern(text: bmel:string, pattern: bmel:string)

Description

Returns true if the text matches the given regular expression pattern. Useful for validating that structured outputs (JSON, XML, email, UUIDs, ISO dates) conform to the expected format, and for detecting undesired patterns such as apology phrases or refusal templates in LLM responses.

Arguments

Parameter Type Required Description
text bmel:string The text to match against.
pattern bmel:string Regular expression pattern (Java/ECMAScript syntax).

Examples

The answer is a UUID
bmel:matches-pattern({invokeAgent:Response Payload}.$.id, '^[0-9a-f-]{36}$')
The structured output starts like a JSON object
bmel:matches-pattern({invokeAgent:Response Payload}.$.output_text, '^\\s*\\{')

← Back to BMEL Reference