write a regular expression to substitute string like c macro?
'hello world "hello"'.replace(regex,"HELLO") => 'HELLO world "hello"'
how to writ开发者_如何学运维e this regex which only substitute 'hello' which is not in quote?
Assuming you're using Javascript:
'hello world "hello"'.replace(/($|[^"])hello(?!")/g,'$1HELLO');
精彩评论