NightDev Community Forums

Command using regex throws unmatched ')' error

Hey,
I’m trying to setup a command which involves some regex, however, the result isn’t what I’d expect.

What I have:

$(eval var string = "$F33H$F32a$F31v$F30n"; string.replace(/\$((\$)|[0-9a-f]{2,3}|[lh]\[.*?\]|.)/gi, ' '))

Error I get:
Invalid regular expression: /[invalid variable]|[0-9a-f]{2,3}|[lh][.*?]|.)/: Unmatched ‘)’

A fiddle using vanilla js, which perfectly works without throwing errors:
https://jsfiddle.net/ay7rsmv8/

How do I get this to work with nightbot? Thankful for any help.

/\ $( (\$)|[0-9a-f]{2,3}|[lh]\[.*?\]|.)/gi

^

The problem is specifically this the reason it’s a nightbot only issue is because nightbot reads $( as the start of a variable so the fix would be to just use the Unicode equivalent \x24 in place of the $ sign

1 Like

Thank you very much, that worked!