I want to match specific words in a sentence using Regex (python)for example
<Loc>UK</Loc> to ban all <fuelV>petrol and diesel</fuelV> in <Date>2040</Date>
The result will be Group1: (Uk) Group2: (ban fuelV Date) Group3:(2024). I tried this
<Loc>(.*)?</Loc>(?:.*(ban).*)<Date>(.*)?</Date>
But the result was UK , ban, 2024
<Loc>(.*)?</Loc>.*(ban).*<(.*)>.*</.*>.*<(Date)>(.*)?</Date>
可以用于匹配 UK、ban、fuelV、Date、2040(每个都在自己的捕获组中。)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.