\'HELLO world \"hello\"\' how to writ开发者_如何学运维e this regex which only substitute \'hello\' which is not in quote?Assuming you\'re using J" />
开发者

write a regular expression to substitute string like c macro?

开发者 https://www.devze.com 2023-03-31 17:59 出处:网络
\'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 J

'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');
0

精彩评论

暂无评论...
验证码 换一张
取 消