Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

restrict simpleType to word characters and spaces except digits

0 views
Skip to first unread message

Anil Mamede

unread,
Apr 4, 2008, 12:54:50 PM4/4/08
to
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

Martin Honnen

unread,
Apr 4, 2008, 1:35:20 PM4/4/08
to
Anil Mamede wrote:

> <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
http://JavaScript.FAQTs.com/

Anil Mamede

unread,
Apr 6, 2008, 12:39:43 PM4/6/08
to

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

Malcolm Dew-Jones

unread,
Apr 7, 2008, 4:06:20 AM4/7/08
to
Anil Mamede (anil....@gmail.com) wrote:
: Hi,

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


What is a word?

I guess that any alphanumeric is a word.
Therefore a number is a word.

So you need a word that has at least one character.

In perl speak (untested))

/(\w*[a-zA-Z]\w*)|(\s+)/

$0.10

0 new messages