regular expressions and multiple match

Discussion in 'Javascript' started by ast, Mar 11, 2011.

  1. ast

    ast Guest

    - sent again -

    hi,

    let us search a.+b in string abcabcabc

    var reg = /a.+b/g;
    var tab = reg.exec("abcabcabc");

    document.write(tab[0]);

    there are 2 possible matchs:

    abcab
    abcabcab

    javascript choose the second one. Why not. But what is the rule ?
    Does javascript always provide the longest possible match ?

    If i want abcab, is there something to do ?

    thx
     
    ast, Mar 11, 2011
    #1
    1. Advertising

  2. ast wrote:

    > - sent again -


    Why?


    PointedEars
    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
     
    Thomas 'PointedEars' Lahn, Mar 11, 2011
    #2
    1. Advertising

  3. ast

    ast Guest

    "Thomas 'PointedEars' Lahn" <> a écrit dans le message de
    news:...
    > ast wrote:
    >
    >> - sent again -

    >
    > Why?
    >


    i beleaved that the first one didnt arrived.
    it arrived finally, but after 2 ou 3 minutes
     
    ast, Mar 11, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay Douglas
    Replies:
    0
    Views:
    619
    Jay Douglas
    Aug 15, 2003
  2. mikko.n

    Regular expressions (multiple match problem)

    mikko.n, Apr 2, 2008, in forum: C Programming
    Replies:
    5
    Views:
    486
    Antoninus Twink
    Apr 2, 2008
  3. Carl Cunningham

    Regular expressions and parenthesis in match text

    Carl Cunningham, Sep 15, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    119
    Carl Cunningham
    Sep 15, 2003
  4. ast
    Replies:
    4
    Views:
    264
    Lasse Reichstein Nielsen
    Mar 11, 2011
  5. Noman Shapiro
    Replies:
    0
    Views:
    240
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page