Java Script Regular Expressions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts

  • Thomas 'PointedEars' Lahn
    Guest replied
    Re: Java Script Regular Expressions

    Gregor Kofler wrote:
    Dempsey.Jeff@gm ail.com meinte:
    >Say I have a url that looks something like this.
    >http://test.com/test/test2/tabid/656/Default.aspx. I need to be able
    >to pull out only the word test2. I wont know that the word is going
    >to be test2 when I use the regular expressions so I need to find
    >everything between / and /tabid because that is the only thing that
    >will be the same no matter what.
    >
    Untested:
    /\/(.*?)\/tabid/
    Less error-prone because not using the non-greedy subexpression and not
    allowing the empty string:

    /\/[^\/]+\/tabid/


    PointedEars
    --
    var bugRiddenCrashP ronePieceOfJunk = (
    navigator.userA gent.indexOf('M SIE 5') != -1
    && navigator.userA gent.indexOf('M ac') != -1
    ) // Plone, register_functi on.js:16

    Leave a comment:


  • Gregor Kofler
    Guest replied
    Re: Java Script Regular Expressions

    Dempsey.Jeff@gm ail.com meinte:
    I am a wreck at regular expressions so I could use a little help.
    >
    Say I have a url that looks something like this.
    http://test.com/test/test2/tabid/656/Default.aspx. I need to be able
    to pull out only the word test2. I wont know that the word is going
    to be test2 when I use the regular expressions so I need to find
    everything between / and /tabid because that is the only thing that
    will be the same no matter what.
    Untested:
    /\/(.*?)\/tabid/

    Gregor


    --
    http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
    http://web.gregorkofler.com ::: meine JS-Spielwiese
    http://www.image2d.com ::: Bildagentur für den alpinen Raum

    Leave a comment:


  • Evertjan.
    Guest replied
    Re: Java Script Regular Expressions

    wrote on 14 feb 2008 in comp.lang.javas cript:
    I am a wreck at regular expressions so I could use a little help.
    >
    Say I have a url that looks something like this.
    http://test.com/test/test2/tabid/656/Default.aspx. I need to be able
    to pull out only the word test2. I wont know that the word is going
    to be test2 when I use the regular expressions so I need to find
    everything between / and /tabid because that is the only thing that
    will be the same no matter what.
    <script type='text/javascript'>

    var t = 'http://test.com/test/test2/tabid/656/Default.aspx';

    t = t.replace(/.+\/([^\/]+)\/tabid\/.+/,'$1')

    alert(t);


    </script>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Leave a comment:


  • Dempsey.Jeff@gmail.com
    Guest started a topic Java Script Regular Expressions

    Java Script Regular Expressions

    I am a wreck at regular expressions so I could use a little help.

    Say I have a url that looks something like this.
    http://test.com/test/test2/tabid/656/Default.aspx. I need to be able
    to pull out only the word test2. I wont know that the word is going
    to be test2 when I use the regular expressions so I need to find
    everything between / and /tabid because that is the only thing that
    will be the same no matter what.

Working...