To someone more experienced working with Regex patterns.
I have a regex pattern that I use to sanitise bad json responses from our backend, replacing empty objects (
{}
) with null, and empty lists (
[]
) with null. The pattern is as follows:
Copy code
Regex("""\{}|\[]""")
This compiles and works just fine in a unit test, but on android it crashes with:
Copy code
Caused by: java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 3
\{}|\[]
^
at java.util.regex.Pattern.compileImpl(Native Method)
at java.util.regex.Pattern.compile(Pattern.java:1344)
at java.util.regex.Pattern.<init>(Pattern.java:1328)
at java.util.regex.Pattern.compile(Pattern.java:950)
at kotlin.text.Regex.<init>(Regex.kt:89)
All I can surmise from this is that the underlying native implementation on Android is different.
r
Rolando Lopez
10/30/2019, 2:50 PM
post an example of the text you’re trying to find over?