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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:51:44+00:00 2026-06-15T14:51:44+00:00

Consider two printk kind of function calls – TRACE_BR(TRACE , END. rc = %d\n,

  • 0

Consider two printk kind of function calls –

TRACE_BR(TRACE ,    "END. rc = %d\n", rc );

TRACE_BR(TRACE, "Value = %s", string );

I am writing a regex to match whole function calls like the above which have % inside the string argument inside them, but should NOT match if the string END is also inside.

I used negative lookahead like this

TRACE_BR\(TRACE.*?(?!END)%.*

I expect this regex to match only the second function call, but its matching the first one too.

I guess I am going wrong somewhere with the greedy * part.

  • 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-15T14:51:45+00:00Added an answer on June 15, 2026 at 2:51 pm

    The regex should be:

    TRACE_BR\(TRACE(?!.*END).*?%.*
    

    This regex will not match the line if END is a substring appearing after TRACE. You may need to modify the regex if you want a more refined matching.

    You can think of the regex as: after I matched TRACE (and etc. in front), from the current position, I would like to look ahead that I cannot find END substring.

    In your regex, if the character after the negative look-ahead assertion is %, the assertion is always true as END substring can’t start there; if the character after the negative look-ahead assertion is not %, the regex will fail to match and backtrack.

    In the hypothetical case that you remove the %, the regex will still allow a string with END to pass, since the sequence of any character .*? will allow the negative look ahead to match at any position along the way, and it can just find a position that is not the start of the string END and match it.

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

Sidebar

Related Questions

Please consider the two following snippets of code: (function f() { var x; try
Consider: function function_name(var_one, var_two) var_one = var_two return var_one end print( function_name(string_one, string_two) )
Consider the following XML document: $xml = [xml] <root><value>one</value><value>two</value></root> And then print the values
Consider two tables: Transactions , with amounts in a foreign currency: Date Amount =========
Consider two methods on the controller CustomerController.cs : //URL to be http://mysite/Customer/ public ActionResult
Consider two dates 2010-03-18 22:30:45 and 2010-03-19 03:30:15 .... How to get the number
let's consider two views that use the same layout composed of: A left column
consider the two template functions below: template <typename T, typename A> T* create(A i)
Consider these two classes mapped to the same table. One is readonly via mutable=false.
Consider the two vectors: v= [1 2 3 4 5 6 7] a=['a' 'b'

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.