Ignoring the line break in regex?

前端 未结 3 1076
旧巷少年郎
旧巷少年郎 2021-01-13 03:04

I have below content in text file

  some texting content \"\"  Test

I read it from

3条回答
  •  醉酒成梦
    2021-01-13 03:33

    By default, the . character will not match newline characters. You can enable this behavior by specifying the Pattern.DOTALL flag. In String.replaceAll(), you do this by attaching a (?s) to the front of your pattern:

    expectedString = inputString.replaceAll("(?s)\\", 
        "NewContent");
    

    See also Pattern.DOTALL with String.replaceAll

提交回复
热议问题