Gossamer Forum
Home : General : Perl Programming :

Case specific Regex

Quote Reply
Case specific Regex
Hello Guys,

I would like to tweak the following regex the way that it allows maximum two capital letters within the entire strin. Is that possible?

^[\w\-\.]{6,30}$

Cheers for all your input

Stuart
Quote Reply
Re: [vacationrentals] Case specific Regex In reply to
Quote:
I would like to tweak the following regex the way that it allows maximum two capital letters within the entire strin. Is that possible?
I think you should divide that regexp into 2 parts:
1) Check if it's valid string: ^[\w\-\.]{6,30}$
2) Check if it has no more than 2 UPPERCASE letters:
Solution: if ( $string =~ /^[\w\-\.]{6,30}$/ && $string =~ /^[[:upper:]]{0,2}$/) { ... }

There are some extended regular expressions which may solve such problem, but most of them are experimental, and should be not used in production environment...

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Case specific Regex In reply to
Hi.

Thanks for reply. I just cannot realize that since I need to enter that in the regex field in Community. That means, I cannot work with conditions and so on.

Cheers
Quote Reply
Re: [vacationrentals] Case specific Regex In reply to
Then likely you will have to write a global or a plugin for GCommunity to solve the problem.
Leave the first regexp in table info, and check input field data coming from the form page to next page, against second regexp placed in a global.

BTW: I think this thread should have been started in GCommunity forum, since it better belongs there, compared to just Perl programming... It's also fine here, but this way, those people who are using GComm, will not find that thread...

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Case specific Regex In reply to
Thanks for the advice.

Stuart