Optimize spoiler regex

Optimize spoiler regex to allow at least one new line.

>!
match this!<

>!match
this!<

>!
match this!<

>!don't
match
this<!

>!
match this
!<

>!match
this
!<
This commit is contained in:
scria1000 2021-11-14 16:34:50 +03:00
parent 839325efbe
commit ef1bdf2fa5

View File

@ -65,7 +65,7 @@ public class Utils {
.replaceAll("((?<=[\\s])|^)/[rRuU]/[\\w-]+/{0,1}", "[$0](https://www.reddit.com$0)") .replaceAll("((?<=[\\s])|^)/[rRuU]/[\\w-]+/{0,1}", "[$0](https://www.reddit.com$0)")
.replaceAll("((?<=[\\s])|^)[rRuU]/[\\w-]+/{0,1}", "[$0](https://www.reddit.com/$0)") .replaceAll("((?<=[\\s])|^)[rRuU]/[\\w-]+/{0,1}", "[$0](https://www.reddit.com/$0)")
.replaceAll("\\^{2,}", "^") .replaceAll("\\^{2,}", "^")
.replaceAll(">!", "&gt;!") // If it's in a code block, html entity remains escaped .replaceAll("(?:>!)(\\n?[\\S\\h]+?\\n?[\\S\\h]+\\n?!<)", "&gt;!$1") // html entity remains escaped inside an inline block
.replaceAll("(^|^ *|\\n *)#(?!($|\\s|#))", "$0 ") .replaceAll("(^|^ *|\\n *)#(?!($|\\s|#))", "$0 ")
.replaceAll("(^|^ *|\\n *)##(?!($|\\s|#))", "$0 ") .replaceAll("(^|^ *|\\n *)##(?!($|\\s|#))", "$0 ")
.replaceAll("(^|^ *|\\n *)###(?!($|\\s|#))", "$0 ") .replaceAll("(^|^ *|\\n *)###(?!($|\\s|#))", "$0 ")