hasmatch

Synopsis

"string" hasmatch 'pattern'

Determine if the string contains a substring that matches the specified pattern. Subsequent calls to this predicate with the same string, pattern combination will check if there is another pattern beyond the first one.

Parameters

"string" - the string to check

'pattern' - a regular expression pattern that defines a substring to match for

Side Effects / Notes

Examples

sub printDocumentTree { local('$tag $content'); while ($1 hasmatch '<(.*?)>(.*?)</\1>') { ($tag, $content) = matched(); println((" " x $2) . "+- $tag $+ : $content"); printDocumentTree($content, $2 + 1); } } $html = "<html><title>Hello World!</title><p>It's a <b>nice</b> day</p></html>"; printDocumentTree($html, 0);

+- html: <title>Hello World!</title><p>It's a <b>nice</b> day</p> +- title: Hello World! +- p: It's a <b>nice</b> day +- b: nice

See Also