簡體   English   中英

如何在正則表達式中排除字符串中的某些單詞(使用 javascript 替換)

[英]How to exclude some word in string in regex (to replace using javascript)

我想在兩個 (") 之間的 select 單詞並排除 (") 之外的其他單詞以使用 javascript 替換替換字符串。 這是我的字符串

接待員:“好的,請稍等。” 過了一會,接待員笑道:“恭喜你,獲得了轉職考試免試證書,有了它,達到一定等級就可以使用了。完成轉職任務后,就可以直接轉專業,很方便的小禮物。”

我想 select "Okay, please wait a moment." 以及"Congratulations, you have obtained a certificate of exemption from the exam for job transfer. With it, you can use it after you reach a certain Level. After completing the job transfer task, you can directly transfer to a specific occupation, a very convenient little gift." 並排除其他。

我嘗試/".+"/g它包括從"okaygift." 並且不排除其他請幫助我,謝謝

我認為它可以工作: /("[^"]+")/g

此正則表達式匹配任何具有初始"的單詞,一個或多個不同於"的字符,最后以"結尾的單詞您可以在此regex101圖像中看到它正則表達式的結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM