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 970421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:48:08+00:00 2026-05-16T02:48:08+00:00

I am trying to parse an HTML file ( non strict one) using JavaScript

  • 0

I am trying to parse an HTML file ( non strict one) using JavaScript

my output should be the same HTML file, but I need to process the internal content of any <script></script> tag. I have a method processScript(script) that does that..

I can assume that there will be no <script/> tags.

I have a pretty clear idea how to it using just split() but I wonder if I can do it better using regex?

  • 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-05-16T02:48:09+00:00Added an answer on May 16, 2026 at 2:48 am

    Parsing HTML with Regex is generally not the best way to do it. Look into DOM parsing instead, using methods like getElementsByName('script') and such. I’d also suggest looking at the w3schools examples on HTML DOM Objects to get you started in the right direction.

    There are a lot of reasons why this is a better approach, a few of them being that 1) Javascript has this DOM Object support already, and it is much easier than using Regex and 2) The language of matching open/close tags (similar to matching parens/brackets/etc) is not a regular language.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse HTML file with libxml2. Usually this works fine, but not
I am trying to parse a bit of data from an HTML file, but
I'm trying to parse an html output file from a program called mirdeep. I
I'm trying to parse and amend some html (as a string) using javascript and
I am trying to parse a non well formed DTD html file which i
I am trying to parse html using BeautifulSoup to try and extract the webpage
I'm trying to parse a html doc using some code I found from this
I'm trying to Parse the following HTML pages using BeautifulSoup (I'm going to parse
I'm trying to parse an html file. The idea is to fetch the span's
I'm trying to parse an HTML file with simplehtmldom and I'm getting this error:

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.