0

I have a multiline file which I read into a String. In this String I need to find rows which are commented.

for example, from the following text:

#................... EPCT Product level setting ................................#......
export EPCT_PRODUCT="OMS"
#export SRC_DB=CHR81/CHR81@CHROMSE9    # EPC/Ref DB source connect string
#export TAR_DB=OMS1OMS/OMS1OMS@CHRDB454  # EPC/Ref DB target

I would like to find #export SRC_DB

For this i wrote the following regex: .*#\\s*export\\s+SRC_DB.*

When I tested it with a single line of text, it matched:

//this will return true:
"#export SRC_DB=CHR81/CHR81@CHROMSE9    # EPC/Ref DB source connect string".matches(".*#\\s*export\\s+SRC_DB.*")

But when trying to mach the multiline string, it doesn't match:

//this returns false
theFullText.matches(".*#\\s*export\\s+SRC_DB.*")

I've tried to add the (is) expression to the regext, as explained heree, but it still doesnt match:

//this also returns false
theFullText.matches("(is).*#\\s*export\\s+SRC_DB.*")
Community
  • 1
  • 1
Alon Adler
  • 3,984
  • 4
  • 32
  • 44

0 Answers0