SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Regex invalid quantifier

    I'm searching for the end of a comment block: str.search("\*/");. However, I get an error that I have an invalid quantifier which means that the asterisk is being taken as a quantifier and not a character and it is giving an error because nothing precedes the asterisk.

    How can I search for the "*/" end of comment sequence without getting an error?

    Thank you,

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    String.search converts its argument to a regular expression.
    Use indexOf to preserve the string, or search(/\*\//) or even ('\\*\\/').


Bookmarks

Posting Permissions

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