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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:30:33+00:00 2026-06-12T09:30:33+00:00

Basically I’m creating a simple Interpreter for our compiler course. Of course this is

  • 0

Basically I’m creating a simple Interpreter for our compiler course. Of course this is not a homework-type question.

Anything that is followed by an asterisks is considered a comment provided that it is not part of the string. I have an escape character in my Interpreter which are brackets.

These are sample syntax for my interpreter

* hello world
OUTPUT: "This is asterisk [*]" * outputs string
OUTPUT: "This is asterisk *"  * outputs string produces syntax error
x = "[*]" & "hello" & "[*]*]" this is already comment which produces syntax error

when I try to run this Regex

[^\[]\*.*

It matches with the following:

* hello world
 * outputs string
 *"  * outputs string produces syntax error
]*]" this is already comment which produces syntax error

My question is, why did the regex “eats” one character before? Wherein I already need

* hello world
* outputs string
*"  * outputs string produces syntax error
*]" this is already comment which produces syntax error
  • 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-12T09:30:34+00:00Added an answer on June 12, 2026 at 9:30 am

    You need to use zero width assertions to stop capturing the condition you just want to match, and
    not “eat” :

    (?<=[^\[])\*.*

    (?<=REGEX_CONDITION) ensures that matching is done, but the matched part ( NOT A “[” in your case) is not included in the matched result.

    Demo : http://regexr.com?32b99

    Edit: to make it fully working, I just added or condition on it

    (?<=[^\[])\*.*|^\*.*
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically from a database I am getting data that is formatted like this nameofproject101
Basically this function is meant to store the height value of the element that
Basically I have some simple code that does some things for files and I'm
Basically, this is a noob question. Forgive. :( Every example in books or on
Basically I am creating a dynamic google map that pulls information from the database,
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I need to verify that a certain program is not running before installation.
Basically i'm having trouble with something that i'm sure is super duper simple but
Basically, I have a CodeIgniter site that registers users through this url: http://website.com/user/register/1 Unfortunately,
Basically, I have a UIImageView that will loop through 8 PNGs over 0.5 seconds.

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.