0

How can i replace values of keys in one like , example :

 <inline-jdbc isolation-level="ReadCommitted" jdbc-driver="com.mysql.jdbc.Driver"
                           jdbc-password="xxxxxx" jdbc-uri="jdbc:mysql://xxxxx"

                            jdbc-username="xxxxx"
                            time-between-eviction-runs-millis="600000" />

as you can see jdbc-password and jdbc-uri are in same line if i run the following command :

s/\(jdbc-uri *= *\).*/\1"jdbc:mysql:\/\/xxxx"/g
s/\(jdbc-password *= *\).*/\1"xxxx"/g
s/\(jdbc-username *= *\).*/\1"xxxx"/g

this command replace jdb-password and jdbc-username and remove jdbc-uri !!

uno-2017
  • 509
  • 1
  • 8
  • 26
  • You can use `"[^"]"` instead of `.*` to find what is between the apostrophes. – billx Sep 11 '16 at 10:53
  • Sorry, I meant `"[^"]+"` – billx Sep 11 '16 at 10:55
  • Indeed, the immediate problem is that you are matching the entire rest of the file with `.*` and replacing it with nothing. More fundamentally, using regex to manipulate a well-defined structured format is misdirected. – tripleee Sep 11 '16 at 11:12

0 Answers0