我试图用Java编写一个正则表达式来摆脱所有的标题,并在一个字符串尾矿标点符号除了"-"
,但保持不变的话中的标点符号。正则表达式删除标题和尾矿标点符号
我想现在有
""
,String regex = "[\\p{Punct}+&&[^-]]";
更换标点符号,但它会删除字中的标点符号太多。我也试图匹配模式:
String regex = "[(\\w+\\p{Punct}+\\w+)]";
和Matcher.maches()
匹配一组,但它给了我零输入String word = "#(*&wor(&d#)("
我想知道什么是对付在正则表达式组匹配的正确方法这种情况下
实例:
Input: @)($&[email protected])($& Output: word
Input: @)($)[email protected]#)(*$&$ Output: [email protected]
你可以放下一些样本数据吗? – Keng 2010-10-28 15:43:41