I am trying to implement a regex for matching all characters except the first character and any character followed by _
in a single word as:
"HELLO_WORLD".replace(^([A-Z]|/_[A-Z]),f => f.toLowerCase()) // Hello_World
But this is giving me error as :
SyntaxError: Unexpected token ^
Can anybody point whats wrong ? I am following this question basically Regex: match everything but specific pattern
EDIT:
This is happening due to missing string literal but I have a followup question now that my regex is not working as I want.
"HELLO_WORLD".replace(/^([A-Z]|_[A-Z])/,f => f.toLowerCase()) // hELLO_WORLD
This is giving hELLO_WORLD
when I want Hello_World