How to check for "/" slash in XML with Regular Expression

rodgerwilco

I have some trouble checking a string in XML for a specific schema. Everything works fine, but the string can contain a "/" Slash which is messing up my regular expression. The expression works fine except for the slash. I tried escaping the slash, but this is not working. The error says, that the pattern would not be a valid regular expression.

Thanks for your help.

<xs:simpleType name="idType">
    <xs:restriction base="xs:string">
        <xs:pattern value="[a-z\+A-Z\/0-9_-]*"/>
    </xs:restriction>
</xs:simpleType>
Wiktor Stribiżew

You do not need to overescape the pattern, use

<xs:pattern value="[a-zA-Z0-9+/_-]*"/>

XSD regex patterns are specified using strings, not regex literals (as is usually the case in JavaScript/Ruby/PHP), without regex delimiters. / is not a special regex metacharacter, and thus should not be escaped.

Actually, + does not have to be escaped either inside a character class, and the hyphen, when placed at the end/start of the character class, does not have to be escaped either.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to match a word based on slash in regular expression

Slash in regular expression in Golang

How to check if the string is a regular expression or not

How to check sequence in string using regular expression

How can I check it with regular Expression?

How to check if the input string is a valid Regular expression?

How to check in Swift if a Regular Expression is valid?

How to check words use regular expression

How can I check for an @ in a regular expression?

Java regular expression and "greedy" or early search for slash

Javascript regular expression: remove first and last slash

Regular Expression to also allow slash "/" with existing Regex

two back slash in SQL procedure with Regular expression

Java Regular Expression check

Netbeans Check Regular Expression

Check date with regular expression

Check the date of the regular expression

How would I write a Regular Expression to capture the value between Last Slash and Query String?

How do I make this regular expression not match anything after forward slash /

Regular Expression in XML Schema

Regular Expression in xml parsing

How to check all pd.DataFrame for regular expression?

How to check if the input is emoji without using regular expression?

How to check if entire string matches regular expression in Javascript?

How to write regular expression to check if substring starts with range of characters?

How to check if a file has an extension (any extension) with regular expression in Bash?

How to check pair of brackets condition using regular expression?

How to check if a given pathname matches a given regular expression in Python

In iOS how to check string against regular expression with boolean result