Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PS

    whithout any space

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    /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
    Last edited by kwhubby; 02-25-2003 at 07:57 AM.
    Kris Hubby
    kwhubby site

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    !

    at once ! :-))

    I try it

    thank you

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    oop just relised. \w is for alphabet chars so a @ or . would not give the result
    Kris Hubby
    kwhubby site

  • #6
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    yes

    yes I get nothing at all

    then if you have a release version of the regular expression ?
    it's welcome !:-))

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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”

  • #8
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ok

    I try at once

    thank you

  • #9
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    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

  • #10
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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”

  • #11
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •