Regular expressions (OMREGEX)

The OMREGEX library implements regular expressions as specified by the XML Schema Datatypes specification.

The following example program reports all links in its input that match a user-supplied regular expression pattern:

     import "beta/omregex.xmd" prefixed by regex.
  
     global string pattern initial { "http://.*\.pdf" }
     
     global regex.regexp compiled-pattern initial { regex.parse pattern }
  
     process
        do xml-parse scan #main-input
           output "%c"
        done
  
     element "link" when attribute "href" matches regex.try compiled-pattern
        output attribute "href" || "%n"
        output "%c"
  
     element #implied
        output "%c"
  
     data-content
        suppress