Confirm Action

Are you sure you wish to do this?

Confirm Cancel
Member Login
Site Notices
1/25/2018 7:38:29 AM
Posted: 11/2/2001 11:34:34 AM EST
Link Posted: 11/2/2001 12:09:49 PM EST
[Last Edit: 11/2/2001 12:04:00 PM EST by Dilbert]
Hi DVDTracker, I assume you are talking PERL regexps? There is slightly different syntax for different languages (various UNIX shells, xemacs, C language, etc). The problem is anything in brackets means you are only matching one letter by default. So your expression matches: a&a.com because it is finding a match with the underlined portion: a&[u]a.com[/u] If you are trying to match any alphanumeric for any number of characters, followed by the .net, .com, or .org domains, your expression should look like this: [b]^[a-zA-Z0-9]+\.com|net|org$[/b] I'm assuming the rest of your syntax is right. Offhand I forget how the logical or operator works (the |). The changes are the ^ anchor. This anchors your regexp to the beginning of the word. That was why your previous regexp was not excluding the "a&" portion in your example -- you didn't tell it that it couldn't have anything in front of the string you were matching. The other change is the "+" modifier. As I said earlier, anything in brackets denotes just one character. So the + modifier means that you are now matching for one or more characters that meet the criterion of [a-zA-Z0-9]. If it was okay to have zero or more characters, you could use the * modifier instead of the +, but I don't think that is what you want in your example. Hope that helps and it wasn't too terribly confusing. Let me know if you need any follow up clarification. Dilbert [Edited to fix UBBcode] __ If it ain't broke, fix it till it is!
Link Posted: 11/2/2001 12:11:08 PM EST
What your regular expression says is to find within the string a pattern that has one letter/number followed by a .com, .net, or .org at the end of the string. Your string "a&a.com" matches that criteria. It has an "a", which is a valid letter/number, followed by a ".com". If you want your string to have only letters/numbers preceding the .com, etc., from the very beginning of the string, you need to write it thusly: ^[a-zA-Z0-9]+\.[com|net|org]$ I think that's right, although I didn't actually check it out myself. YMMV.
Link Posted: 11/2/2001 12:16:32 PM EST
[Last Edit: 11/2/2001 12:11:24 PM EST by DVDTracker]
Link Posted: 11/2/2001 12:28:33 PM EST
Link Posted: 11/2/2001 3:38:48 PM EST
DVDTracker, your last rule allows for invalid domain names that start with a - to still pass. Below is the rule I developed years ago to look for valid e-mail addresses: ^[0-9a-z]([-_.]?[0-9a-z]\.?)*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]+$
Link Posted: 11/2/2001 3:46:01 PM EST
Boy, good luck with that working 100%. Now all you have to do is include all the national domains like ".co.uk" for commercial UK sites, etc, ad nauseum. You might try Network Solutions for a list of all TLDs.
Link Posted: 11/2/2001 3:49:47 PM EST
Top Top