WalletConnect / walletconnect-utils

Javascript Utilities for WalletConnect
MIT License
113 stars 75 forks source link

fix: safe json parse #155

Closed ganchoradkov closed 10 months ago

ganchoradkov commented 11 months ago

updated regex breakdown


(?<!"): Negative lookbehind assertion ensures that the match is not immediately preceded by a double quote (").

(?<=:): Positive lookbehind assertion ensures that the match is immediately preceded by a colon (:).

\b: Word boundary to ensure that the match is a whole word.

(\d{17,}|(?:[9](...))): Alternation for two possible patterns:

\d{17,}: Matches a sequence of at least 17 digits.
(?: ... ): Non-capturing group for a nested pattern.
[9](...): Matches the digit 9 followed by a nested pattern for specific numeric values.
(?=[,\}\]]|$): Positive lookahead assertion ensures that the match is immediately followed by either ,, }, ], or the end of the string.