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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:58:15+00:00 2026-05-20T18:58:15+00:00

Can someone share a regex that find all not double-slashed commented println in java

  • 0

Can someone share a regex that find all not double-slashed commented println in java code?

Example:

System.out.println("MATCH")   /*this line match*/
//    System.out.println("DOESN'T MATCH")  /*this line doesn't match*/

(I’m using this regex into throw eclipse searching dialog)

  • 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-05-20T18:58:16+00:00Added an answer on May 20, 2026 at 6:58 pm

    Okay, as I already mentioned, regex is not the right tool, so if you end up using my suggestion, be sure to backup your source!

    The following regex matches a single line that has System.out.print in it, without // or /* before it (in that same line!).

    (?m)^((?!//|/\*).)*System\.out\.print.*
    

    or simply:

    (?m)^[ \t]*System\.out\.print.*
    

    which can then be replaced with:

    //$0
    

    to comment it.

    Again: this will go wrong with multi line comments, and as Kobi mentioned, stuff like /* // */ System.out.print... to name just two of the many cases this regex will trip over.

    Also consider the line:

    System.out.println("..."); /*
    comments
    */
    

    you don’t want to end up with:

    //System.out.println("..."); /*
    comments
    */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone share a simple example of using the foreach keyword with custom objects?
Can someone share how to make items in a ListViewer scrollable? Source code will
Can someone share an easy example to see how people are overriding methods called
Can someone please share a program in java which does the following. if given
Can someone share example of using Monkeyrunners broadcastIntent method. To run Browser with certain
Can someone share how to practically implement gridview sorting and handle that event if:
Can someone share their experiences with s#arp architecture. we have decided to follow mvp
Can someone share a good way to save the program state (UINavigationController stack, etc)
Can someone please share a extremely simple version of JQuery Ajax with pagination??
Can someone give an example of a good time to actually use unsafe and

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.