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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:25:17+00:00 2026-06-15T21:25:17+00:00

Writing a very simple script parser as part of a school project, and while

  • 0

Writing a very simple script parser as part of a school project, and while it’s not required I’m curious if it can be done with only a regular expression.

The syntax is similar to ASP, where a script begins with <% and ends with %>.

It only supports one command “pr”, which is the same as echo or Response.Write.

Right now I’m using this regular expression to find script blocks:

(<%\s*([\s\S]*?)\s*%>)

But if I have a command like this:

<% pr "%>"; %>

…it obviously only matches:

<% pr "%>

Is there a way using pure regex to to ignore closing tags that are within quotes? My main worry is that it might match tags that are between quotes, but actually outside of them, if that makes sense. For example…

<% pr "hello world"; %> "

Technically the closing tag is surrounded by quotes, but it’s not inside an “open” then “close” quote, rather the other way around.

If this is possible with regex that would be pretty neat, otherwise I suspect that if I wanted to support this functionality I would have to manually iterate through the incoming text and parse the blocks out myself, which is no big deal really either.

Thanks!

  • 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-15T21:25:18+00:00Added an answer on June 15, 2026 at 9:25 pm

    I think this one should suit your needs: <%(".*?"|.*?)*?%> (see the Demo).

    Explanation:

    While .* matches as long as possible, .*? matches as little as possible.

    For example (using pseudo-code),

    "#foo# #bar#".matches(/#(.*)#/).group(1) // will return ["foo# #bar"]
    

    while

    "#foo# #bar#".matches(/#(.*?)#/).group(1) // will return ["foo", "bar"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a parser for a very simple grammar in javacc. It's beginning to
I'm currently writing a very simple script in PythonScript for a basic ASCII checkbox
I am writing a very simple Bash script that tars a given directory, encrypts
I am writing a very simple script that calls another script, and I need
I'm writing a script to convert very simple function documentation to XML in python.
I am writing a very simple comparison in shell bash script, but I never
I'm writing a very simple script to control a process, script checks if the
I am writing a very simple ruby script and has a few checks: if
I'm very new to Ruby. I've recently finished writing a simple script, which uses
so I have a very simple script I'm writing to be a calculator so

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.