1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2009
    Rep Power

    What's an invalid quantifier?

    I'm trying to make a javascript regular expression that matches just the video code from a youtube address:

    var youtube = 'http://www.youtube.com/watch?v=44xb9nb2P7g';
    var youtube = youtube.match(/(?<=[=])\w{11}/g);

    I've tested it on gskinner and it works, but in my browser firebug says there's an invalid quantifier.
  2. #2
  3. No Profile Picture
    User 165270
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Rep Power
    The quantifier is the repetition part: {11}. But I highly doubt that is the problem. The error message might be caused by the internal regex engine's incapability of parsing the look-behind. I have no experience with this Firebug tool, but JavaScript does not support look-behinds, so that is most probably the issue here. You will have to match the equals sign and group the eleven characters after it:

    javascript Code:

    and access the contents of group 1. Or simply remove the equals sign.

    Comments on this post

    • Arty Ziff agrees

IMN logo majestic logo threadwatch logo seochat tools logo