I have the following string:
uri=/abc/jkncedknj/dslkmfldsmf/245?X_Security_Token=o93457yndo49758yewrwet&accountId=bob123
I want to essentially obfuscate the x_secuirty_token
, so essentially delete all but 4 characters in the string: o93457yndo49758yewrwet
Currently I'm following these steps to achieve it:
- find the token within the string
- extract it from the string
- get the first four digits of the token and place it back in the string
The strings are dynamic so I'm essentially looking into replacing anything from the =
after the X_Security_Token
to &accountId=bob123
I've tried the following:
[Token][=]{a-zA-z0-9}+[&accountId]
but it's complaining that the syntax would be incorrect. I've tried other variations but it still doesn't work. I'm pretty new to regex.