Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要找到位于两个星号符号之间的所有值*data1* *data2* *data3* *data4* *data5*我如何在java中为这个特定的字符串设置正则表达式。我试过 indexof ..但它不起作用
*data1* *data2* *data3* *data4* *data5*
这工作正常...
String pattern = "\*([^*^\s*$]+)\*"; Pattern pt = Pattern.compile(pattern); Matcher mat = pt.matcher(data);
仅查找值(不带星号)。(找不到完全空白的值):
(?<=\*)(\s*[^*\s]+\s*)