0
I have a string like this "87 CAMBRIDGE PARK DR".I have used the below regular expression
to remove the last word "DR", but it also removing the word "PARK" also..
下面是我的代碼...用正則表達式去除字符串中的最後一個單詞?
String regex = "[ ](?:dr|vi|tes)\\b\\.?"; /*regular expression format*/
String inputString ="87 CAMBRIDGE PARK DR"; /*input string */
Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputString);
inputString = matcher.replaceAll("");
Now the out put is "87 CAMBRIDGE"..
但我需要出去放爲 「87劍橋公園」
感謝您rply ... – Rahul
歡迎您:) –
您可以通過點擊右標記接受我的答案,如果它真的幫助你......和或能給予好評的答案。 –