Regular Expression - DodgeIntrepid.Net Forums - Dodge Intrepid, Concorde, 300m and Eagle Vision chat
 
LinkBack Thread Tools Rate Thread Display Modes
post #1 of 5 (permalink) Old 05-22-2002, 04:16 PM Thread Starter
 
Join Date: Jun 2001
Posts: 145
Feedback: 0 / 0%
 
Regular Expression

anybody good with regular expression using asp/vbScript?
bvwib is offline  
Sponsored Links
Advertisement
 
post #2 of 5 (permalink) Old 05-22-2002, 08:13 PM
 
Join Date: Feb 2002
Posts: 212
Feedback: 0 / 0%
 
what do you mean by "regular expression"? What is it you are trying to do?
chrisgaddy is offline  
post #3 of 5 (permalink) Old 05-23-2002, 09:43 AM Thread Starter
 
Join Date: Jun 2001
Posts: 145
Feedback: 0 / 0%
 
regular expressions
Hi,
im trying to filter out email addresses for meta characters
for security purposes.
bvwib is offline  
Sponsored Links
Advertisement
 
post #4 of 5 (permalink) Old 05-23-2002, 10:19 AM
 
Join Date: Feb 2002
Posts: 212
Feedback: 0 / 0%
 
Here ya go!

Here's the solution: I hope this displays correctly

<%
Dim arAdd(5)
Dim rgExpress

arAdd(0) = "[email protected]"
arAdd(1) = "Chris Gaddy"
arAdd(2) = "8500 Wolf Lake"
arAdd(3) = "901-555-3002"
arAdd(4) = "901-555-0608"
arAdd(5) = "[email protected]"

Set rgExpress = New RegExp

with rgExpress
.Pattern = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"
.IgnoreCase = True
.Global = True
End With

For i = 0 to 5
Response.Write "<br>" & rgExpress.Replace(arAdd(i),"")
Next

Set rgExpress = Nothing
%>
chrisgaddy is offline  
post #5 of 5 (permalink) Old 05-23-2002, 11:27 AM Thread Starter
 
Join Date: Jun 2001
Posts: 145
Feedback: 0 / 0%
 
Hey Chris thanks! your code certainly prevents metas.

this is what i was using

<%@ Language=VBScript %>
<% Option Explicit %>
<% dim brin


brin = "[email protected]"

dim ExpressionChecker
dim exprChecked

Set ExpressionChecker = new RegExp

With ExpressionChecker
good characters.
.Pattern = "[\w\.-][email protected]([a-z0-9-]+\.)+[a-z]{2,}\.?$"
.IgnoreCase = false
.Global = true
end with

set exprChecked = ExpressionChecker.Execute(brin)
'"" if it agrees with the pattern restrictions then good email
if exprChecked.count > 0 then
response.Write "pattern was found, good email." & "<br>" & brin
else
'if it doesn't then bad email
response.Write " no pattern was found , bad email address" & "<br>" & brin

end if

%>

i thought that [\w] was equivalent to [a-zA-Z_0-9] but for some reason it considered for example:

[email protected]#[email protected] - correct, but if did
@#[email protected] - it was incorrect. (I was missing a ^).:crazy: nevermind:crazy




one concern i have with you code, which mine also has it that is allows for example

[email protected]

it allows more than one dash or period in between words. any way to prevent this?

update:

this one seems to work
^([\w](\.){0,1}(-){0,1})[email protected]([a-z0-9-]+\.)+[a-z]{2,}\.?$"

thanks again:

Last edited by bvwib; 05-23-2002 at 12:04 PM.
bvwib is offline  
Sponsored Links
Advertisement
 
Reply

Quick Reply
Message:
Options

Register Now



In order to be able to post messages on the DodgeIntrepid.Net Forums - Dodge Intrepid, Concorde, 300m and Eagle Vision chat forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.

Member names may only be composed of alpha-numeric characters. (A-Z and 0-9)

!!ATTENTION ADVERTISERS!! If you intend on advertising anything on this forum, whatsoever, you are required to first contact us here . Additionaly, we do NOT allow BUSINESS NAMES unless you are an Authorized Vendor. If you own a business, and want to do sales on this site via posting or private message, you will need to follow the rules. Shops, Stores, Distributors, Group Buys without being authorized will see your account terminated.

User Name:
Password
Please enter a password for your user account. Note that passwords are case-sensitive.

Password:


Confirm Password:
Email Address
Please enter a valid email address for yourself.

Email Address:
OR

Log-in










Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page
Display Modes Rate This Thread
Linear Mode Linear Mode
Rate This Thread:



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

 
For the best viewing experience please update your browser to Google Chrome