我是新來的正則表達式,所以沒有得到這個。 我需要在Java中匹配兩個String
s,其中一個將有x的數量,其他可以在這些地方有任何字符。匹配兩個字符串,一個用x,另一個用任何字符
For example -
String 1 - this is the time xxxx when i get up
String 2 - this is the time 0830 when i get up
這兩個字符串應匹配並返回true。
請建議。
謝謝。
許多人提到這個問題並不是很清楚。我會添加更多的細節 -
1. x can appear 2 to any number of times.
2. Strings will be dynamic, or in other words, they'll be passed to a method -
public boolean doesMatch(String str1, String str2) {
// matching code
return false;
}
所以另一個例子是 -
this is xxxday and i xxxx it
this is friday and i like it
這兩個字符串也應該匹配。
請澄清你正試圖完成,因爲它不清楚。 – stryba 2014-10-07 12:07:42