Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8195379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:07:08+00:00 2026-06-07T05:07:08+00:00

HTML comments may use inline JavaScript as special blocks for old browsers that don’t

  • 0

HTML comments may use inline JavaScript as special blocks for old browsers that don’t support JS code. These blocks look like this:

<!--
some js code
//-->

I want to distinguish ‘true’ html comments from such in JS code. I’ve written this regex:

/<!--[^//]*?-->/g

So I want to exclude matches with a double slash inside, but the regex regards // as a character set of / and /, not as entire double slash //. What can I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:07:10+00:00Added an answer on June 7, 2026 at 5:07 am

    Character classes, as you noted, only match a single character, so you can’t use them here. But you can make use of negative lookahead assertions:

    /<!--(?:(?!//)[\s\S])*-->/g
    

    (assuming this is JavaScript).

    Explanation:

    <!--     # Match <!--
    (?:      # Try to match...
     (?!//)  #  (asserting that there is no // ahead)
     [\s\S]  #  any character (including newlines)
    )*       # ...any number of times.
    -->      # Match -->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scraping pages using BeautifulSoup; trying to filter out links that end in ...html#comments Code
What is that peice of the HTML code that allows me to provide comments
assuming the following html (minus the comments and nbsp; etc that xQuery wont process
Here is an old add in to quickly comment out HTML code. Maybe I
A website I am working on has to use the Facebook Connect Old JavaScript
I have a series of files containing html comments ( <!-- some comment -->
I am rendering out a ViewUserControl (.ascx file) in a view: <% Html.RenderPartial(Comments, Model.Comments);
I'm trying to extract a portion of html between 2 comments. here is the
Which is the correct doxygen format for PHP comments? #1 /** Create HTML for
I am checking problem related to rendering and fonts. Comments in GraphicsEnvironment.html#getAllFonts() mentions '

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.