ibrahim olgaç
ibrahim olgaç

Reputation: 33

regex validation for alphanumeric and smaller character

I need to use < character in a regular expression,

"^[a-zA-Z0-9>_/.\<-]*$"

This pattern is supposed to match alphanumeric characters and > _ / . -

However, I cannot use < character in it.

I tried \< but it did not work.

Upvotes: 2

Views: 1009

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626738

Inside an XML attribute, you need to use XML entities for < and >.

This is a variant with just a lessthan sign

 <f:validateRegex pattern="^[a-zA-Z0-9&lt;_/.-]*$"/> 

This will match both greaterthan and lessthan signs

<f:validateRegex pattern="^[a-zA-Z0-9&gt;&lt;_/.-]*$"/> 

Upvotes: 1

Related Questions