簡體   English   中英

使用正則表達式比較字符串

[英]Compare a String using regex comparison

我必須使用正則表達式比較字符串。

" 2017 年 8 月 29 日發貨"

Shipped on ”將是句子中的起始詞。我做了它,但它沒有按預期工作。有人可以幫我嗎

"(^Shipped on.* \\w.+\\s\\d{2},\\s\\d{4})"

正則表達式Shipped on\\s\\w+\\.\\s\\d{2},\\s\\d{4}

Java代碼

String string = "Shipped on Aug. 29, 2017";
Boolean isMatch = string.matches("Shipped on\\s\\w+\\.\\s\\d{2},\\s\\d{4}");
System.out.println(isMatch); // true

暫無
暫無

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

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