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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:34:01+00:00 2026-06-16T00:34:01+00:00

In my java file there are many sql queries assigned to java strings like:

  • 0

In my java file there are many sql queries assigned to java strings like:

/* ... */
String str1 = "SELECT item1, item2 from table1 where this=that and MYWORD=that2 and this3=that3";
/* ... */
String str2 = "SELECT item1, item2 from table1 where this=that and" + 
                " MYWORD=that2 and this3=that3 and this4=that4";
/* ... */
/* ... */
String str3 = "SELECT item1, item2 from table2 where this=that and this2=that2 and" +
                " this3=that3 and this4=that4";
/* ... */
String str4 = "SELECT item1, item2 from table3 where this=that and MYWORD=that2" +
                " and this3=that3 and this4=that4";
/* ... */
String str5 = "SELECT item1, item2 from table4 where this=that and this2=that2 and this3=that3";
/* ... */

Now I want to find out the ‘SELECT…’ queries that doesn’t contain the word ‘MYWORD’ in it.

From one of my previous S/O question I got the answer how to find all the ‘SELECT...‘ queries, but I need to extend that solution to find the ones that doesn’t contain certain word.

I have tried the regex SELECT(?!.*MYWORD).*; that can’t find the multiline queries (like str3 above), finds only the single line ones.

I’ve also tried the regex SELECT[\s\S]*?(?!MYWORD).*(?<=;)$ that finds all the queries and is unable to determine whether the word ‘MYWORD’ is present in the query or not.

I know I’m very near to the solution, still can’t figure it out.
Can anyone help me, please?
(I am using notepad++ on windows)

  • 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-16T00:34:02+00:00Added an answer on June 16, 2026 at 12:34 am

    The problem with the first regex is that . doesn’t match a newline. In normal regexes, there is an option to change that, but I don’t know whether that feature exists in notepad++.

    The problem with the second regex is that is matches “select, then some stuff, then anything that doesn’t match MYWORD, then more stuff, then a semicolon” Even if MYWORD exists, the regex engine will happily match (?!MYWORD) to some other part of the string that is not MYWORD.

    Something like this should work (caveat: not tested on Notepad++):

    SELECT(?![^;]*MYWORD)[^;]*;
    

    Instead of ., match anything that is not a semicolon. This should allow you to match a newline.

    Beyond that, it is also important that you don’t allow a semicolon to be part of the match. Otherwise, the pattern can expand to gobble up multiple SELECT statements as it tries to match.

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

Sidebar

Related Questions

There are many libraries for reading/writing/appending text from/into a csv file in java. Which
How do I print a .dwg file from Java? Is there is an API
Is there a way to prepend a line to the File in Java, without
Is there a standard Java library that handles common file operations such as moving/copying
Are there any libraries create programs in java that uses a file as a
I have java source code in a text file. There has to be entered
We use Tomcat for our java web application. There is a properties file under
I have a java file Test.java (below) which uses Guava's HashMultiMap (downloaded from http://code.google.com/p/guava-libraries/
There are many file operations in my program, such as copy/move/delete files. Of course,
i know there is many types of encode and decode and from what i

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.