Gossamer Forum
Quote Reply
Form Regex
The field area Form Regex-
What does this do? How is it used? What is the correct syntax?
Thanks-

Quote Reply
Re: Form Regex In reply to
It is the validation test for allowable data in those fields.

For instance, it can make sure a date is formatted, or a field contains only numbers, or at least n characters. It's any valid regex (regular expression). It's the "pattern" part and it's passed into perl to check.

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: Form Regex In reply to
How would a telephone number be checked in the regex? I mean what are the placeholders for letters or numbers? As in 000-000-0000? Or an email address like name@name.com?

I wish there was more complete docs available Frown

Quote Reply
Re: Form Regex In reply to
There is, it's called "Mastering Regular Expressions",
http://postcardsportal.com/...es/Detailed/466.html

If you intend to do anything non-trivial with regexes you _NEED_ this book!

As for specific examples, many of these issues have been discussed in the Links SQl forum, and in the PERL forum. This is "pure perl", and has nothing specific to do with Links SQL. You can search here for 'regex' or 'regular expression' to find them.

I really do need to add all the books to the FAQ site.

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: Form Regex In reply to
Thanks-
Life is a learning process...

Quote Reply
Re: Form Regex In reply to
I also neeed to update the descriptions, looks like the prices changed since Imported them last...

soo much to do.... sooooo little time.

PUGDOGŪ
PUGDOGŪ Enterprises, Inc.
FAQ: http://pugdog.com/FAQ


Quote Reply
Re: Form Regex In reply to
Pugdog,

Question on Regex:

In Reply To:
It is the validation test for allowable data in those fields.
Can this field only be used for validation or can I also use this regex expression to parse the data in a field?

i.e. If I'd want to replace all /n line ends in a text field with a <BR> tag, can I do it from here? When do these regex expressions get applied? Before the data is written to the database or when it get's called to build the page?

Safe swoops
Sangiro
http://www.dropzone.com/
Quote Reply
Re: [pugdog] Form Regex In reply to
Quote:
or a field contains only numbers

I'm pretty sure this must have been answered before but I can't seem to find it through a search. I'm looking for a simple regex that will check for numbers only. [0-9]

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Form Regex In reply to
Something like this maybe?

^\d+$

That should match only digits.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Form Regex In reply to
In Reply To:
Something like this maybe?

^\d+$

Thanks Andy!

One more question: How do I change this to allow for number only or no data at all. I don't want to force people to fill in this field (which the regex above does) but if they do choose to fill it in, it needs to be numbers only.

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] Form Regex In reply to
I'd like to know that too :)

I'm sure it has something to do with a : and ? in the front .. but I can't remember (been a while since I used that feature, and now I can't find the documentation on that particular feature Frown).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [sangiro] Form Regex In reply to
What about to give a JScript a chance? Wink

Just mu 2 cents Tongue

zaaron

---------
GetLokal Reviews
Quote Reply
Re: [sangiro] Form Regex In reply to
^\d*$

* should allow for 0 or more numbers where as + allows for 1 or more numbers.
Quote Reply
Re: [afinlr] Form Regex In reply to
heheh... I never said I was good at Regex Tongue (still learning, as we all are).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [afinlr] Form Regex In reply to
Excellent. Thank Laura.

Safe swoops
Sangiro