im trying to match a json block with a regex (embe...
# announcements
w
im trying to match a json block with a regex (embedded in another document), and just the simple regular expression
Regex("{}")
shows up with the errors
Dangling metacharacter
on both the opening and closing bracket
{
or
}
don't have special meaning in regular expressions so im not so sure what the meaning is
s
Just remembered, they definitely do -
a{4,6}
for example matches
a
at least four and no more than six times
you’ll probably want to just escape them
w
hm i guess in my case it doesnt have any meaning though, but yeah it seems like i had to do
\\{
only for the first curly bracket
woah so in pure kotlin you only need to escape the first one
but in android it crashes unless you escape both
k
well you need one to excape the
{
but because it's in a string literal I assume, you need to escape said
\
w
yeah
im talking about the curly brackets though as in you need to escape both curly brackets only on android. in plain kotlin i can just escape the first one
k
I guess the the kotlin one has better error recovery or something
w
the IDE tells me the second escape is unnecessary in both which is the odd part