Selector

Regex Match Filters

Methods that filter found elements using regular expressions on text, value, attribute, href, src, or placeholder - for when exact matching is too strict.

Methods that filter found elements using regular expressions on text, value, attribute, href, src, or placeholder - for when exact matching is too strict.

The Regex match methods work identically to their exact-match counterparts but accept .NET regular expression patterns instead of literal strings. MatchTextRegex filters by visible text content. MatchValueRegex by the value attribute. MatchAttributeRegex by an attribute value. MatchHRefRegex by href. MatchSrcRegex by src. MatchPlaceholderRegex by placeholder. Use these when element content includes dynamic portions (IDs, dates, counts) that vary between page loads.

Examples

GPAL Fluent: High-level fluent C# API

//Regex patterns use standard .NET syntax. Remember to escape backslashes in C# strings - a regex pattern \d+ in a C# string literal is written as "\\d+" or use a verbatim string @"d+".

// Match any link whose href starts with /product/ var productLink = GPAL.Selector .WithCSS("a") .MatchHRefRegex("^/product/\d+$"); // Match any row whose text contains an order number pattern var orderRow = GPAL.Selector .WithCSS("tr") .MatchTextRegex("ORD-[0-9]{6}");