簡體   English   中英

使用正則表達式獲取多行文本中的值

[英]Using regex to get values in multiline text

我有以下情況:

我想使用Regex在下面的JS代碼的.html()之后提取“”之間的所有字符串。

到目前為止,這是我所做的:

(\.html\()?"(.+)"\s*\+*
\.html\("(.+)"(\s*\+\s*\n\s*"(.+)")*

但不適用於所有行。

任何幫助將不勝感激。

謝謝。

JavaScript代碼

     sym.getSymbol("popup").$("main").html("Delamination at Sharp Points and Corners");
     sym.getSymbol("popup").$("sub").html("<span style='font-family: abel_probold'>Defect:</span> Bond separates easily at the tip of a sharp edge or corner.<br><br>" +
         "<span style='font-family: abel_probold'>Common cause:</span> Very little adhesive area to hold the application in place<br><br>" +
         "<span style='font-family: abel_probold'>Corrective action:</span> When possible, eliminate sharp points. Validate bond performance with wash testing.</div>");

您可以匹配引號和引號之間的所有內容:

string.match(/\"([^\"]*)\"/g)

您可以使用此正則表達式:

string.match(/\.html\((.+?)\)/gs)

https://regex101.com/r/xW5yR3/1

暫無
暫無

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

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