[英]String between to strings regex expression
所以我有以下字符串:
<GetMyeBaySellingResponse xmlns="urn:ebay:apis:eBLBaseComponents" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Timestamp>2016-06-03T08:56:30.123Z</Timestamp>
<....>
<.....>
</GetMyeBaySellingResponse>
我想有一個正則表達式將提取.....之間的主要問題是
有時到達
<GetMyeBaySellingResponse xmlns="urn:ebay:apis:eBLBaseComponents">
所以我需要一些東西來尋找<GetMyeBaySellingResponse
的開頭和第一個>
作為前綴
所以我需要一個匹配器(start with <GetMyeBaySellingResponse and end with the first >) and (end with <GetMyeBaySellingResponse/>)
使用以下正則表達式。
/<GetMyeBaySellingResponse[^>]*>(?:([^<]*)<GetMyeBaySellingResponse\/>)?/
第1組將包含字符串(如果有)。
針對措辭不一的問題進行了更新。 上面的表達式不適用於問題中的更新文本。 嘗試使用以下正則表達式來匹配GetMyeBaySellingResponse
中的任何文本,包括任何XML元素。
/<GetMyeBaySellingResponse[^>]*>(?:((?:(?!<\/GetMyeBaySellingResponse>)(?:.|\s))*)<\/GetMyeBaySellingResponse>)?/
(?:[\n]*(?:(?:<.+>)(.*)(?:<.+>)))\n*
我認為這個簡單的代碼可以完成這項工作。
<GetMyeBaySellingResponse [\S\s]*<\/GetMyeBaySellingResponse>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.