You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Madtyn <ma...@gmail.com> on 2009/09/21 00:33:11 UTC

About regexps on Tapestry

Hello!

I have some doubts about the regexp validators in Tapestry. I have
learnt some about regexp but after making some validating with
success, I haven't been able to do two things:

1) Which flavour of regexp does Tapestry use? I have looked for it on
the Internet but I couldn't find out. I know that there are the regexp
from Javascript, Jakarta and many others but I don't know which one of
them Tapestry's belongs to.

2) Because of the former, I can't make a correct regexp for name and
surname fields. I've tried the following:

nombre-regexp=^([a-zÑñA-Z _.-])+         // This is the name
apellidos-regexp=^([a-zÑñA-Z _.-])+       // This is the surname

   I'm trying to avoid all characters which are not letters, (you
shouldn't have a name containing numbers, dots....) but this is the
more accurate I got and allow numbers (not at the beginning) and it's
not what I want.

   Maybe some spanish Tapestry experts around here could help me with
getting the 'ñ' spanish letter into the regular expressión, as well as
accents.


Thank you very much on advance.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: About regexps on Tapestry

Posted by Andreas Andreou <an...@di.uoa.gr>.
AFAIK \p{Alpha},  \p{javaLowerCase}, \p{Lower} and others mentioned
all deal with ascii

If you want to match any letter in any language then
\p{L}
and that matches accented ones as well.

On Mon, Sep 21, 2009 at 1:41 PM, Madtyn <ma...@gmail.com> wrote:
> I already use quickRex, a wonderful and handy tool but I didn't know
> which flavour did I have to use, so I was confused about that.
>
> About the \p{javaLowerCase}\p{javaUpperCase}, it seems to have
> problems with 'ñ' spanish letter and letters with graphical accents.
> Maybe I did something wrong. I finally put:
>
> nombre-regexp=^[\p{javaLowerCase}\p{javaUpperCase}\p{javaWhitespace}]+$
> apellidos-regexp=^[\p{javaLowerCase}\p{javaUpperCase}\p{javaWhitespace}-]+$
>
> Only added the whitespace for composite names to be possible.
>
>
> Anyway, the other pattern seems to work perfectly now.
>
> If someone is interested, these are the patterns I use:
>
> nombre-regexp=^([a-zÑñçÇA-ZáéíóúÁÉÍÓÚ ])+
> apellidos-regexp=^([a-zÑñçÇA-ZáéíóúÁÉÍÓÚ -])+
>
> Almost identical to the Alejandro's one.
>
>
>
>                                                Thanks, Thiago, Martin
> and Alejandro.
>
>
>
>
>
> 2009/9/21 Martin Strand <do...@gmail.com>:
>> There are java specific operators that match letters:
>> \p{javaLowerCase}
>> \p{javaUpperCase}
>>
>> So to make sure a string only contains letters (in any language) you could
>> do this:
>>
>> ^[\p{javaLowerCase}\p{javaUpperCase}]+$
>>
>>
>> If you're using Eclipse you might find this plugin handy, it allows you to
>> test regular expressions with ease:
>> http://bastian-bergerhoff.com/eclipse/features/web/QuickREx/toc.html
>> http://bastian-bergerhoff.com/eclipse/features/web/installation.html
>>
>> Martin
>>
>> On Mon, 21 Sep 2009 00:33:11 +0200, Madtyn <ma...@gmail.com> wrote:
>>
>>> Hello!
>>>
>>> I have some doubts about the regexp validators in Tapestry. I have
>>> learnt some about regexp but after making some validating with
>>> success, I haven't been able to do two things:
>>>
>>> 1) Which flavour of regexp does Tapestry use? I have looked for it on
>>> the Internet but I couldn't find out. I know that there are the regexp
>>> from Javascript, Jakarta and many others but I don't know which one of
>>> them Tapestry's belongs to.
>>>
>>> 2) Because of the former, I can't make a correct regexp for name and
>>> surname fields. I've tried the following:
>>>
>>> nombre-regexp=^([a-zÑñA-Z _.-])+         // This is the name
>>> apellidos-regexp=^([a-zÑñA-Z _.-])+       // This is the surname
>>>
>>>   I'm trying to avoid all characters which are not letters, (you
>>> shouldn't have a name containing numbers, dots....) but this is the
>>> more accurate I got and allow numbers (not at the beginning) and it's
>>> not what I want.
>>>
>>>   Maybe some spanish Tapestry experts around here could help me with
>>> getting the 'ñ' spanish letter into the regular expressión, as well as
>>> accents.
>>>
>>>
>>> Thank you very much on advance.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: About regexps on Tapestry

Posted by Madtyn <ma...@gmail.com>.
I already use quickRex, a wonderful and handy tool but I didn't know
which flavour did I have to use, so I was confused about that.

About the \p{javaLowerCase}\p{javaUpperCase}, it seems to have
problems with 'ñ' spanish letter and letters with graphical accents.
Maybe I did something wrong. I finally put:

nombre-regexp=^[\p{javaLowerCase}\p{javaUpperCase}\p{javaWhitespace}]+$
apellidos-regexp=^[\p{javaLowerCase}\p{javaUpperCase}\p{javaWhitespace}-]+$

Only added the whitespace for composite names to be possible.


Anyway, the other pattern seems to work perfectly now.

If someone is interested, these are the patterns I use:

nombre-regexp=^([a-zÑñçÇA-ZáéíóúÁÉÍÓÚ ])+
apellidos-regexp=^([a-zÑñçÇA-ZáéíóúÁÉÍÓÚ -])+

Almost identical to the Alejandro's one.



                                                Thanks, Thiago, Martin
and Alejandro.





2009/9/21 Martin Strand <do...@gmail.com>:
> There are java specific operators that match letters:
> \p{javaLowerCase}
> \p{javaUpperCase}
>
> So to make sure a string only contains letters (in any language) you could
> do this:
>
> ^[\p{javaLowerCase}\p{javaUpperCase}]+$
>
>
> If you're using Eclipse you might find this plugin handy, it allows you to
> test regular expressions with ease:
> http://bastian-bergerhoff.com/eclipse/features/web/QuickREx/toc.html
> http://bastian-bergerhoff.com/eclipse/features/web/installation.html
>
> Martin
>
> On Mon, 21 Sep 2009 00:33:11 +0200, Madtyn <ma...@gmail.com> wrote:
>
>> Hello!
>>
>> I have some doubts about the regexp validators in Tapestry. I have
>> learnt some about regexp but after making some validating with
>> success, I haven't been able to do two things:
>>
>> 1) Which flavour of regexp does Tapestry use? I have looked for it on
>> the Internet but I couldn't find out. I know that there are the regexp
>> from Javascript, Jakarta and many others but I don't know which one of
>> them Tapestry's belongs to.
>>
>> 2) Because of the former, I can't make a correct regexp for name and
>> surname fields. I've tried the following:
>>
>> nombre-regexp=^([a-zÑñA-Z _.-])+         // This is the name
>> apellidos-regexp=^([a-zÑñA-Z _.-])+       // This is the surname
>>
>>   I'm trying to avoid all characters which are not letters, (you
>> shouldn't have a name containing numbers, dots....) but this is the
>> more accurate I got and allow numbers (not at the beginning) and it's
>> not what I want.
>>
>>   Maybe some spanish Tapestry experts around here could help me with
>> getting the 'ñ' spanish letter into the regular expressión, as well as
>> accents.
>>
>>
>> Thank you very much on advance.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: About regexps on Tapestry

Posted by Martin Strand <do...@gmail.com>.
There are java specific operators that match letters:
\p{javaLowerCase}
\p{javaUpperCase}

So to make sure a string only contains letters (in any language) you could do this:

^[\p{javaLowerCase}\p{javaUpperCase}]+$


If you're using Eclipse you might find this plugin handy, it allows you to test regular expressions with ease:
http://bastian-bergerhoff.com/eclipse/features/web/QuickREx/toc.html
http://bastian-bergerhoff.com/eclipse/features/web/installation.html

Martin

On Mon, 21 Sep 2009 00:33:11 +0200, Madtyn <ma...@gmail.com> wrote:

> Hello!
>
> I have some doubts about the regexp validators in Tapestry. I have
> learnt some about regexp but after making some validating with
> success, I haven't been able to do two things:
>
> 1) Which flavour of regexp does Tapestry use? I have looked for it on
> the Internet but I couldn't find out. I know that there are the regexp
> from Javascript, Jakarta and many others but I don't know which one of
> them Tapestry's belongs to.
>
> 2) Because of the former, I can't make a correct regexp for name and
> surname fields. I've tried the following:
>
> nombre-regexp=^([a-zÑñA-Z _.-])+         // This is the name
> apellidos-regexp=^([a-zÑñA-Z _.-])+       // This is the surname
>
>    I'm trying to avoid all characters which are not letters, (you
> shouldn't have a name containing numbers, dots....) but this is the
> more accurate I got and allow numbers (not at the beginning) and it's
> not what I want.
>
>    Maybe some spanish Tapestry experts around here could help me with
> getting the 'ñ' spanish letter into the regular expressión, as well as
> accents.
>
>
> Thank you very much on advance.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: About regexps on Tapestry

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Sun, 20 Sep 2009 21:02:57 -0300, Alejandro Scandroli  
<as...@codehaus.org> escreveu:

> On Mon, Sep 21, 2009 at 12:33 AM, Madtyn <ma...@gmail.com> wrote:
>> 1) Which flavour of regexp does Tapestry use? I have looked for it on
>> the Internet but I couldn't find out. I know that there are the regexp
>> from Javascript, Jakarta and many others but I don't know which one of
>> them Tapestry's belongs to.

Tapestry uses the standard Java regex flavour, described here:  
http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html.  
Reading it, it looks to be very similar to the Perl 5 regex.

-- 
Thiago H. de Paula Figueiredo
Consultor, desenvolvedor e instrutor em Java
Coordenador e professor da Especialização em Engenharia de Software com  
Ênfase em Java da Faculdade Pitágoras
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: About regexps on Tapestry

Posted by Alejandro Scandroli <as...@codehaus.org>.
Hi Madtyn

Your pattern looks OK to me, it should work, just be sure the file
where you are writing the pattern is encoded in UTF-8.

This is the pattern I use: [a-zA-ZáéíóúñçÁÉÍÓÚÑÇ]+
Again, be sure your file is correctly encoded in UTF-8 and it should work.

Saludos.

--
Alejandro Scandroli - http://weblog.amneris.es/
Amneris: We build process-driven web applications.
http://www.amneris.es



On Mon, Sep 21, 2009 at 12:33 AM, Madtyn <ma...@gmail.com> wrote:
> Hello!
>
> I have some doubts about the regexp validators in Tapestry. I have
> learnt some about regexp but after making some validating with
> success, I haven't been able to do two things:
>
> 1) Which flavour of regexp does Tapestry use? I have looked for it on
> the Internet but I couldn't find out. I know that there are the regexp
> from Javascript, Jakarta and many others but I don't know which one of
> them Tapestry's belongs to.
>
> 2) Because of the former, I can't make a correct regexp for name and
> surname fields. I've tried the following:
>
> nombre-regexp=^([a-zÑñA-Z _.-])+         // This is the name
> apellidos-regexp=^([a-zÑñA-Z _.-])+       // This is the surname
>
>   I'm trying to avoid all characters which are not letters, (you
> shouldn't have a name containing numbers, dots....) but this is the
> more accurate I got and allow numbers (not at the beginning) and it's
> not what I want.
>
>   Maybe some spanish Tapestry experts around here could help me with
> getting the 'ñ' spanish letter into the regular expressión, as well as
> accents.
>
>
> Thank you very much on advance.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org