Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-25-2003, 06:17 AM   PM User | #1
angiras
Regular Coder

 
Join Date: Dec 2002
Location: France
Posts: 522
Thanks: 0
Thanked 0 Times in 0 Posts
angiras is an unknown quantity at this point
Regular Expression

sorry I don't know where to post it !

I am looking for a regular expression , I mus tfind in full text

mailto: john@starplus.com "

then

what is between mailto: and "

?

thank you
angiras is offline   Reply With Quote
Old 02-25-2003, 06:18 AM   PM User | #2
angiras
Regular Coder

 
Join Date: Dec 2002
Location: France
Posts: 522
Thanks: 0
Thanked 0 Times in 0 Posts
angiras is an unknown quantity at this point
PS

whithout any space
angiras is offline   Reply With Quote
Old 02-25-2003, 06:48 AM   PM User | #3
kwhubby
Regular Coder

 
Join Date: Nov 2002
Location: Carmel California
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
kwhubby is an unknown quantity at this point
/mailto:(\w*)"/
should be good (the match would be [1] of the returned results, not [0])

edit: use arq = the variable of the text being searched.match(/mailto:(\w*)"/)
and then arq[1] is what you want
__________________
Kris Hubby
kwhubby site

Last edited by kwhubby; 02-25-2003 at 06:57 AM..
kwhubby is offline   Reply With Quote
Old 02-25-2003, 07:22 AM   PM User | #4
angiras
Regular Coder

 
Join Date: Dec 2002
Location: France
Posts: 522
Thanks: 0
Thanked 0 Times in 0 Posts
angiras is an unknown quantity at this point
!

at once ! :-))

I try it

thank you
angiras is offline   Reply With Quote
Old 02-25-2003, 08:44 PM   PM User | #5
kwhubby
Regular Coder

 
Join Date: Nov 2002
Location: Carmel California
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
kwhubby is an unknown quantity at this point
oop just relised. \w is for alphabet chars so a @ or . would not give the result
__________________
Kris Hubby
kwhubby site
kwhubby is offline   Reply With Quote
Old 02-25-2003, 09:29 PM   PM User | #6
angiras
Regular Coder

 
Join Date: Dec 2002
Location: France
Posts: 522
Thanks: 0
Thanked 0 Times in 0 Posts
angiras is an unknown quantity at this point
yes

yes I get nothing at all

then if you have a release version of the regular expression ?
it's welcome !:-))
angiras is offline   Reply With Quote
Old 02-25-2003, 10:09 PM   PM User | #7
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
var pattern = /mailto:([^"]+)"/;

or

var pattern = /mailto:(\.+?)"/;

Either should work
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Old 02-26-2003, 06:36 AM   PM User | #8
angiras
Regular Coder

 
Join Date: Dec 2002
Location: France
Posts: 522
Thanks: 0
Thanked 0 Times in 0 Posts
angiras is an unknown quantity at this point
ok

I try at once

thank you
angiras is offline   Reply With Quote
Old 02-26-2003, 02:45 PM   PM User | #9
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
Quote:
Originally posted by beetle
var pattern = /mailto:([^"]+)"/;

or

var pattern = /mailto:(\.+?)"/;

Either should work

Hmm, /mailto:([^"]+)"/ should work perfectly, but just to be sure, make it case insensitive.

/mailto:(\.+?)"/ on the other hand shouldn't work - you escape the fullstop from being any character to being just a fullstop. You'll not catch any valid address that way.

Code:
// This would be better:
var pattern=/mailto:(.+?)"/i;
// But I really suggest you do it in this way instead:
var pattern=/mailto:([-_a-z~.]+@[-_a-z~.]+)"/i;
/* Why? Because that way, even though you'll not get full email address validation out of it, you'll at least make sure you get a full address. */
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Old 02-26-2003, 03:24 PM   PM User | #10
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
Thx liorean, that 2nd pattern is bogus

However, I disagree with your 2nd pattern. Email addresses can have an apostrophe as well, and I'm not sure whatever else.

I think "better" is a decision best left up to angiras and what he/she is using these email addresses for.
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Old 02-26-2003, 03:33 PM   PM User | #11
angiras
Regular Coder

 
Join Date: Dec 2002
Location: France
Posts: 522
Thanks: 0
Thanked 0 Times in 0 Posts
angiras is an unknown quantity at this point
HE :-)

it works I get it with

Dim expr As String = "[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}"
Dim patt As String = "mailto" + expr + ")"

it's vb Net but regular expressions are the same

thank you to all for helping
angiras is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:33 AM.


Advertisement
Log in to turn off these ads.