Ignoring the line break in regex?

前端 未结 3 1071
旧巷少年郎
旧巷少年郎 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:32

    You need to use Pattern.DOTALL mode.

    replaceAll() doesn't take mode flags as a separate argument, but you can enable them in the expression as follows:

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

    Note, however, that it's not a good idea to parse HTML with regular expressions. It would be better to use HTML parser instead.

提交回复
热议问题