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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:28:04+00:00 2026-06-13T21:28:04+00:00

I would like a regex pattern to match all lines in a text file

  • 0

I would like a regex pattern to match all lines in a text file that has the follow pattern:

TcQuery {dynamic_content} Alias "{dynamic_content}" New

If the text file has these two lines:

//tcquery c_query alias "qrybklog" new           <= This one shouldn´t be found because there is two backslashes before TcQuery.

tcquery c_query alias "qrybklog" new             <= I want a pattern to match this line

I´ve tried this but both lines are matched:

        var prw = System.IO.File.ReadAllText(@"d:\backlog.prw", Encoding.ASCII);

        prw = "//TcQuery c_query Alias teste1 new";
        prw = "\nTcQuery c_query Alias teste2 new";
        prw = "\nTcQuery c_query Alias teste3 new";
        prw = "\n//TcQuery c_query Alias teste4 new";
        var regexTcQuery = new Regex("TcQuery+[ *]+[0-9a-zA-Z_]+[ *]+alias+[ *]+[0-9a-zA-Z_\"]+[ *]new$", RegexOptions.IgnoreCase);

        var resultTcQuery = regexTcQuery.Matches(prw);
  • 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-13T21:28:05+00:00Added an answer on June 13, 2026 at 9:28 pm

    Use singleline and ignorecase option with this regex

    (?<!\/\/)\s*?\btcquery\b(.*?)\balias\b.*?new
    

    (?<!\/\/) checks for // before tcquery

    .*? is a lazily matches 0 to many characters.If you use .* then it would match the last tcqurey skipping ibetween tcquery matches

    \b is a non-word boundary.This allows us to match separate words

    \s matches 0 to many space which can be any of the [\n\r\t\f]


    If you want to get the c_query text you can do this

    List<string> lst=Regex.Matches(input,@"(?<!\/\/)\s*?\btcquery\b(.*?)\balias\b.*?new").Cast<Match>().Select(x=>x.Groups[1].Value).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to match url pattern that has optional segments. I have URL-s
I have a binary file that I would like to regex search/replace hex bytes
What would the regex pattern be to match all decimals but the first one?
I would like to regex match a sequence of bytes when the string '02
I would like to construct regex (in JavaScript) that would return: for string test
I would like to craft a case-insensitive regex (for JavaScript) that matches street names,
I have some files that I would like to rename using regex and powershell,
I would like to create a regex to validate customer names. This would be
I would like to generate a regex for a string like S67-90. I used
I would like to know the regex for splitting up the decimal number from

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.