Regex Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreRegex Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 16th, 2009, 09:50 AM
cardi777 cardi777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 6 cardi777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 53 sec
Reputation Power: 0
Totally confused

Hi all.

I am using a jquery validator plugin.

I am trying to make my own plugins, but all the ones on the internet seems to have charaters that are not present in the supplied validation.

Here is what the supplied regex looks like...

Code:
"telephone":{
"regex":"/^[0-9\-\(\)\ ]+$/",
"alertText":"* Invalid phone number"},	
"email":{
"regex":"/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/",
"alertText":"* Invalid email address"},	
"date":{
"regex":"/^[0-9]{4}\-\[0-9]{1,2}\-\[0-9]{1,2}$/",
"alertText":"* Invalid date, must be in YYYY-MM-DD format"},


The regex I found which I would like to use looks like this:

Code:
^\d*[0-9](\.\d*[0-9])?$


Am I seeing two kinds of regex here? I don't see ? characters in the supplied regex. And slashes look like they are used differently.

Confused!

Cheers,
Doug

Reply With Quote
  #2  
Old July 16th, 2009, 02:42 PM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,805 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 17 h 43 m 13 sec
Reputation Power: 6112
the / character is used as a boundary, to show where the regexp begins and ends. Some regexp parsers don't use them, so sometimes you see them omitted. ^ and $ designate the beginning and ending of a string, respectively. So where you see /^something$/ it can be considered the same as ^something$ for example purposes.

As for the rest of your post...what do you mean? You posted 3 regular expressions inside a javascript array, then posted a fourth and said something about question marks. Question marks are special characters in regular expressions, if you would like to include one in a pattern it must be escaped, like this: \?

Other than that, you'll have to be more specific.

-Dan
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
  #3  
Old July 16th, 2009, 06:56 PM
cardi777 cardi777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 6 cardi777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 53 sec
Reputation Power: 0
interesting...

ahh I see.

Sorry about my wording, let me explain a bit further with some coherence!

I am trying to pass particular regexp through this javascript parser. But I can't other regexp ones I find to work from regexlib dot com.

I tried adding those boundary charaters but it still doesn't work. So I can't figure out where I am going wrong! I thought that perhaps is the regex is going through a parser, I need to do more then add boundaries. As in maybe some characters need to be replaced or added within the regex code so it doesn't get screwed up in the parser.

I am new to regex. You mentioned regexp. Are they different things?

Thanks for your help and patience!

Cheers,
Doug

Reply With Quote
  #4  
Old July 17th, 2009, 08:23 AM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,805 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 17 h 43 m 13 sec
Reputation Power: 6112
Some people include the P, some don't. Larry Wall (the inventor of Perl, and arguably the inventor of modern regular expressions) calls the "reg[Ee]xp?"

What are you trying to do with that regular expression you posted? It looks like you're just trying to validate decimal numbers with at least one digit before the decimal place. If that's the case, you really just want:
Code:
/^\d+(\.\d+)?$/


To add it to your script you'd do:
Code:
"telephone":{
"regex":"/^[0-9\-\(\)\ ]+$/",
"alertText":"* Invalid phone number"},	
"email":{
"regex":"/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/",
"alertText":"* Invalid email address"},	
"date":{
"regex":"/^[0-9]{4}\-\[0-9]{1,2}\-\[0-9]{1,2}$/",
"alertText":"* Invalid date, must be in YYYY-MM-DD format"},
"someNumberType":{
"regex":"/^\d+(\.\d+)?$/",
"alertText":"* Invalid number type.  There must be a leading digit before the decimal, and digits after the decimal if one is included."},
I don't know how your validation thing works, but wherever you check for "telephone" you can change it to "someNumberType" to get the new regexp and the new error message.

-Dan

Reply With Quote
  #5  
Old July 17th, 2009, 09:52 AM
cardi777 cardi777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 6 cardi777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 53 sec
Reputation Power: 0
Thanks

Thanks for that. I will give it a go!

Reply With Quote
  #6  
Old July 17th, 2009, 10:17 AM
cardi777 cardi777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 6 cardi777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 53 sec
Reputation Power: 0
... hmm didn't work... but

HMM well it didn't work. I thought it would because it looked to short and simple. My attention now turns to the rules for accepting regex because I now know that the problem probably isn't the regex.

Here is a function tied in with the functions. Maybe I can change something in here to make the rules more acceptable?
Code:
var loadValidation = function(caller) {VALIDATIONS TO BE EXECUTED

rulesParsing = $(caller).attr('class');
rulesRegExp = /\[(.*)\]/;
getRules = rulesRegExp.exec(rulesParsing);
str = getRules[1]
pattern = /\W+/;
result= str.split(pattern);	
		
var validateCalll = validateCall(caller,result)
return validateCalll
};


Does anything in there ring any bells? ITs almost as if it only accepts the most primitive regex's. From looking at the supplied regex validations, they don't employ that many expressions as compared to make examples I have seen.

And ideas?

Cheers,
Doug

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreRegex Programming > Totally confused

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap