"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.


"string" - the string to check

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

Side Effects / Notes


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