[英]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.