In XML schemas, you can use a regular expression with the “pattern” facet to restrict the values a type allows to certain regex matches. For this, the XML Schema standard defines its own regular expression flavor. This flavor is limited compared to the regex syntax used by .NET or Java. It is optimized for its intended use (input validation) and for easy implementation in custom hardware and software that needs to process XML at high speeds.
The XQuery 1.0 and XPath 2.0 Functions and Operators standard defines three functions fn:matches, fn:replace, and fn:tokenize that take a regular expression as one of their parameters. They use a regex syntax that extends the XML Schema flavor with several features that are available in many modern regex flavors, but not in the XML Schema flavor.
The Saxon library is the de facto standard implementation of the XML Schema and XPath standards. When you select XML Schema or XPath as your application, RegexBuddy emulates the exact syntax and behavior of regular expressions in Saxon 10 to 12.
First, use RegexBuddy to define a regex or retrieve a regexp saved in a RegexBuddy library. Rely on RegexBuddy’s clear regex analysis, which is constantly updated as you build the pattern, rather than dealing with the cryptic regex syntax on your own. Detailed help on that syntax is always only a click away.
If you copied a regex written for another programming language, simply paste it into RegexBuddy, select the original language, and then convert the regex to the XML Schema or XPath regex flavor.
If you created a new regular expression, test and debug it in RegexBuddy before using it in your XML schemas. Test each regex in RegexBuddy’s safe sandbox without risking precious data. Quickly apply the regex to a wide variety of input and sample data, without having to produce that input through your XML tools.
Finally, let RegexBuddy generate an XML snippet that you can copy and paste directly into whichever XML editor you use. Just choose what you want to use the regex for, and a fully functional code snippet is ready. You can change the names of types and attributes to suit your naming style or the current situation, which RegexBuddy automatically remembers.
Don’t worry about properly replacing ampersands and angle brackets with XML entities. Just tell RegexBuddy what you want to do, and you will get the proper XML code straight away.