Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试验证价格范围格式。以下是字符串的顺序:
"MSRP $250.00 - Event Price $129.00"
我试过这样:
String t=price1.replace("$","T"); t= t.replace(" ", ""); MSRPT([0-9]+).([0-9]+)-EventPriceT([0-9]+).([0-9]+)
但它没有被匹配。
谢谢
利用:
MSRP\s\$([0-9]+)\.([0-9]+).*?\$([0-9]+)\.([0-9]+)
请注意,您需要转义$并且.- 点是“任何”字符
$
.
但我会写:
MSRP\s+\$([\d\.]+).*?Event\sPrice\s+\$([\d\.]+)
您将拥有 1 美元和 2 美元的价格值字符串