1

I'm having trouble with two regular expressions that I need to use to validate urls in an xsd file.

I understand that there is a slight difference in how Schema uses regex compared to other systems.

Does anyone have any valid regex to separately validate a url and an email in XSD schema?

designermonkey
  • 1,078
  • 2
  • 16
  • 28

1 Answers1

0

For e-mail :

<xsd:pattern value="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}"/>

Not that xsd schema always implies anchors so this should have to match your entire string.

Edit : Above regex is pretty basic. I suggest you read this :

Using a regular expression to validate an email address

For more info. Regarding the url, depending on how complex you want your validation to be there are about a million regexes you could use. And schema regex is rather limited to say the least.

Community
  • 1
  • 1
FailedDev
  • 26,680
  • 9
  • 53
  • 73