我有下面的java腳本來提取字符串中出現「=」後的單詞。正則表達式解釋
例如:
string strOld="ActionDate=11/20/2014 12:00:00 AM ";
strOld.substr(strOld.indexOf(type)).substr(type.length +1, strOld.substr(strOld.indexOf(type)).substr(type.length).indexOf(" "))
這將提取「2014年11月20日」,從上述string.Since這是被「=」後存在的單詞。
如何使用正則表達式重寫?
我想要在同一個字符串變量中重新出現「=」的情況下得到逗號分隔的日期。
在有多個標誌的情況下:
輸入:字符串strOld = 「ActionDate = 11/20/2014年12:00:00 AM SuspensionCode = 123」; 輸出: 「11/20/2014,123」
你能寫完整的代碼嗎? – SmartestVEGA
@buckley這個'=(\ S +)'就夠了。而且你還必須加上'g'修飾符。 –
單件作品,但多個我把以下表達,但它不工作 – SmartestVEGA