#include "demo_guard.h" void regex_row(String label, String result, String expect) { bool pass = (result == expect); <> "> } void regex_bool_row(String label, bool result, bool expect) { regex_row(label, result ? "true" : "false", expect ? "true" : "false"); } RENDER(Request& context) { String text = "Contact ops@example.test or tag #uce, #docs, and café."; DValue first_email = regex_search("(?[A-Za-z0-9._%+-]+)@(?[A-Za-z0-9.-]+)", text); DValue tags = regex_search_all("#(?[A-Za-z0-9_]+)", text); StringList pieces = regex_split("\\s*,\\s*", "uce, components, markdown"); <>

UCE Test: Regular Expressions

UCE regex functions use PCRE2 and return ordinary UCE strings, lists, and DValue values.

sample =

Validation And Search

All Matches

Replace And Split

$1\", \"#uce\")", regex_replace("#([A-Za-z0-9_]+)", "$1", "#uce"), "uce"); regex_row("join(regex_split(\"\\\\s*,\\\\s*\", ...), \"|\")", join(pieces, "|"), "uce|components|markdown"); regex_row("case-insensitive flag", regex_search("uce", "Hello UCE", "i")["match"].to_string(), "UCE"); ?>

Structured Result

Read the regex API documentation

}