<@U5UU34LPK> yup. This is simple. I need add only ...
# getting-started
p
@karelpeeters yup. This is simple. I need add only
.
and
-
(internal token char) in regex and run.
k
And number's don't really work, something lile
(?!\d)(\w+)
might be a bit closer.
Out of interest, where are you getting these almost-json strings?
p
From AWS Cognito 😞
k
Huh that's strange. Looking trough some random docs I see well-formed json: https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AddCustomAttributes.html
p
Yes. But there is only requests. I have not 100% confidence of valid my response.
Och. I broke this string:
eyJraWQi5iuerhteiurht-ertertert.OiI3Qnw
k
(?!\d+)([\w-\.]+)
Is fine as long as it doens't start with a number.
Looks like
(?!\d+[^\w])([\w-\.]+)
is always fine, as long as there's no floats and booleans.
p
(?!\d+[^\w])([\w-\.]+)
looks perfect!
k
I hope you made sure there's really no other way, because I wouldn't be happy about this simple smile
p
Sadly yes. I make another
.replace()
and finaly I got valid JSON.
o
Can’t resist 🙂 https://stackoverflow.com/a/1732454/18575
😎 1
k
A must-read when abusing regex!