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

  • Home
  • SEARCH
  • 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 9272169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:48:23+00:00 2026-06-18T15:48:23+00:00

I’m currently building a web-server which can receive request, and send back a response.

  • 0

I’m currently building a web-server which can receive request, and send back a response.
I’ve managed to embed a port of Google’s v8 JavaScript engine to c# (javascript.net) to my project and I want to parse a requested file and run the server-sided JavaScript code that in it. I decided that this code will be contained inside a 2-character brackets, <: for opening and :> for closing. I started to parse it with code I written but after encountering some problems which made the code more messy and probably not very efficient I decided to go ahead and try using RegEx (I had you study it because I’ve never used it before). BUT WAIT. After talking to my friend about it he send me this post RegEx match open tags except XHTML self-contained tags I understood that it isn’t a good idea…
So my question is, How do I parse such thing? (Taking efficiency and clean code into account, after all it’s a webserver).
Thanks in advance!

  • 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-18T15:48:24+00:00Added an answer on June 18, 2026 at 3:48 pm

    Ideally, what you’d want to do is hook into V8’s lexer so you don’t end up catching things inside of strings and such. I looked at the source to that .NET wrapper, however, and it looks like it doesn’t allow that much customization. Instead, you may want to create a small state machine. You’d probably want at least these states:

    • Literal data (for stuff outside of your <: and :> tags)
    • Left angle bracket (for once you’ve consumed a < and are waiting for a potential :)
    • Script state (for stuff inside of your <: and :> tags)
    • Script double-quote string state
    • Script double-quote string escape state
    • Script single-quote string state
    • Script single-quote string escape state
    • Script slash state (for comments and regular expressions1)
    • Script line comment state
    • Script block comment state
    • Script block comment star state
    • Script regular expression state
    • Script colon state (for when you’ve encountered a : and are unsure whether a > or something else is next)

    It may not be so quick to write as a regular expression, but it would be able to handle code like this:

    Hello, world!
    <:
        document.write("At least you won't think the script :> ends there.");
    :>
    

    1On second thought, it’s probably not so easy to detect regular expressions.

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

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am confused How to use looping for Json response Array in another Array.
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words

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.