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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:33:10+00:00 2026-05-20T10:33:10+00:00

I want to write regular expressions to read data inside blocks of <script></script> in

  • 0

I want to write regular expressions to read data inside blocks of <script></script> in HTML. Being script, I suppose there is flexibility in whitespace. In order to make my regex patterns robust, I would have to anticipate varying amounts of whitespace. Perhaps there is an easier way than putting many whitespace matchers in my patterns. For example, there might be a normalizer? (The normalizer would of course have to understand string literals in order not to ruin them.)

I’m using .NET and the Regex class. (Note: the Regex class has a ECMAScript option which I thought might enable a feature that understands script whitespace but reading the description of it, it seems not.)

Edit: Regex class has an option “IgnorePatternWhitespace” but note this grants flexibility in writing regex patterns. It doesn’t change the parsing/matching behaviour.

I am trying to avoid putting whitespace matchers in many locations in the following kind of patterns:

const string propertyKey = @""".+""";
const string propertyValue = @""".+""";
string property = propertyKey + @"\x3a" + propertyValue;
string actionProperties = property + @"(\x2c" + property + @")*";
string actionPattern = @"\x7b" + actionProperties + @"\x7d";
string contentPattern = actionPattern + @"(\x2c" + actionPattern + @")*";
string corporateActionsPattern = @"corp_actions\s*:\s*""\s*[" + contentPattern + @"]\s*""";
  • 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-20T10:33:11+00:00Added an answer on May 20, 2026 at 10:33 am

    The imperfect solution was to normalize the script by removing all whitespace (not merely normalizing down to a single space). The integrity of string literals was respected. Regex matchers become easier to write. Note the Javascript will be ruined because reserved words and identifiers will run into each other when whitespace is removed but the risk of problems is low if the goal is to parse only the “data” parts (ie: string literals, numbers, and the punctuation that surrounds them).

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

Sidebar

Related Questions

Is there a good set of tutorials for regular expressions? Particularly in a TextMate
I have a file that I want to read in using the File::Slurp module
I am currently creating dynamic SSIS packages that import/export and access data between a
I often have to write code in other languages that interact with C structs.
In a nutshell , I want to have different faces for some types of
I am trying to use regular expression to search a document fo a UUID
I don't understand, why does the following regular expression: ^*$ Match the string 127.0.0.1?
In java i would like to read a file line by line and print
So I wrote this short script (correct word?) to download the comic images from
I very new to Python, and fairly new to regex. (I have no Perl

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.