1

I want to store "~ s/\n|\s+|.*?=|;//g;" in a string variable.

Can anyone help me in this. Thanks in advance.

carloabelli
  • 4,161
  • 3
  • 38
  • 67
Monti Chandra
  • 402
  • 5
  • 21
  • possible duplicate of [Raw Strings in Java - for regex in particular](http://stackoverflow.com/questions/1256667/raw-strings-in-java-for-regex-in-particular) – user158037 Jul 21 '15 at 14:14

1 Answers1

1

You have to replace \ by \\ in a Java String literal. See https://docs.oracle.com/javase/tutorial/essential/regex/literals.html (at the bottom).

That is

String regExp = "~ s/\\n|\s+|.*?=|;//g;";

should work.

Christian Fries
  • 15,175
  • 10
  • 54
  • 65