Reputation: 1190
I need a regexp to get all string inside a tags like it: <- -> inside this tags include any character, numbers, spaces, carriage return etc. i have this regexp:
Pattern.compile("<-(.+?)->")
but it not detect a special sequence as: \r \n etc.
Upvotes: 1
Views: 432
Reputation: 784918
but it not detect a special sequence as: \r \n etc
It won't match newline unless you use Pattern.DOTALL
flag as in:
Pattern p = Pattern.compile("<-(.+?)->", Pattern.DOTALL);
OR else you can use (?s)
flag:
Pattern p = Pattern.compile("(?s)<-(.+?)->");
Pattern.DOTALL
makes dot match new line character so .+?
will also match \r
,\n
etc.
Upvotes: 2
Reputation: 20129
The .
character does not match line breaks. This is why you are having the issue.
Upvotes: 0