我有一個這樣的字符串:1/80% of all goods sold for $44 million dollars or more/90/55
所以基本上我想有模式的字符串:使用Java Pattern和Matcher搜索模式,包括標點符號,如斜線
「一定數量」「斜槓「‘一些文本與任何標點符號,包括斜槓’,‘斜線’,‘一些數量’,‘斜線’,‘一定數量的’
我不能只用在向前的StringTokenizer和記號化斜槓,因爲我的文字塊可能有正斜槓。我對在java中使用模式和匹配器很陌生。有關我如何做到這一點的任何線索?或者可能有用的教程?提前致謝!根據需要
^\d+/.*/\d+/\d+$
添加捕獲組:
設計模式?我會重申你的問題。 – davidbuzatto 2012-07-24 15:33:28
因此,分隔符是第一個斜線和最後兩個斜槓,而其他任何斜線都是文本的一部分? – 2012-07-24 15:35:04
Pattern和Mather是Java中的部分或正則表達式(正則表達式)機制。你可以在這裏找到更多信息(http://docs.oracle.com/javase/tutorial/essential/regex/) – Pshemo 2012-07-24 15:39:01