[英]Javascript Regex - Quotes to Parenthesis
我想以某种方式使用 Javascript 中的正则表达式将字符串序列“*”替换为 (*)。 将引号之间的内容替换为左括号和右括号之间的内容。
例如“苹果”到(苹果)
有任何想法吗?
你可以尝试类似的东西
replace(/"(.*?)"/g, "($1)")
例子
"this will be \"replaced\"".replace(/"(.*)"/, "($1)")
=> this will be (replaced)
"this \"this\" will be \"replaced\"".replace(/"(.*?)"/g, "($1)")
=> this (this) will be (replaced)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.