restrict simpleType to word characters and spaces except digits

A

Anil Mamede

Hi,

I'm having an hard time to build a regular expression that:
- Will accept words;
- Will accept spaces;
- But cannot accept digits;

Examples:

This is a game
Olá Mundo
Módulo A

An initial approach was:

<xs:simpleType name="nomeType">
<xs:restriction base="xs:string">
<xs:maxLength value="255" />
<xs:pattern value="[\w\s]+" />
</xs:restriction>
</xs:simpleType>

But this will accept values like this:

Módulo 1234

I could use "[\w\s]+" [a-zA-Z\s] but i've to accept other letters from
ISO-8859-15 like á or Í.

The attempt:


<xs:simpleType name="nomeType">
<xs:restriction base="xs:string">
<xs:maxLength value="255" />
<xs:pattern value="[\w\s]+" />
<xs:pattern value="\D+" />
</xs:restriction>
</xs:simpleType>

does not work either.

Thanks in advance,

Anil Mamede
 
M

Martin Honnen

Anil said:
<xs:simpleType name="nomeType">
<xs:restriction base="xs:string">
<xs:maxLength value="255" />
<xs:pattern value="[\w\s]+" />
</xs:restriction>
</xs:simpleType>

The specification <URL:> defines
\w
as
"[#x0000-#x10FFFF]-[\p{P}\p{Z}\p{C}] (all characters except the set
of "punctuation", "separator" and "other" characters)"
so that includes digits.

If you use
<xs:pattern value="\P{N}+"/>
then you allow anything that is not a "Number" character.

Or you need to list the characters you want to allow.
 
A

Anil Mamede

Anil said:
<xs:simpleType name="nomeType">
<xs:restriction base="xs:string">
<xs:maxLength value="255" />
<xs:pattern value="[\w\s]+" />
</xs:restriction>
</xs:simpleType>

The specification <URL:> defines
\w
as
"[#x0000-#x10FFFF]-[\p{P}\p{Z}\p{C}] (all characters except the set
of "punctuation", "separator" and "other" characters)"
so that includes digits.

If you use
<xs:pattern value="\P{N}+"/>
then you allow anything that is not a "Number" character.

Or you need to list the characters you want to allow.

Martin Honnen thanks a lot. I'll try that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top