1
得到的只有完全匹配的字符串,我需要從一個字符串匹配"test"
或"test,"
像如何從比賽
"test, testhellowowo, wowtest,"
嘗試1
test[,]?
將所有三個匹配,因爲所有的字符串包括test
,無論發生什麼後。
嘗試2
^test[,]?$
它不會匹配任何除非字符串是test
或test,
預期結果
"test, testhellowowo, wowtest,".match(x) // should match `test,`
"testhellowowo, wowtest,".match(x) // should not match anything
是做到了,如果你回答我能接受的結束。 –