小编Sub*_*nya的帖子

匹配&&和|| 特殊字符

我正在编写一个Lucene应用程序来匹配&&(双&符号)和||(OR或双管道).

我想写一个正则表达式来匹配输入文本中的任何&&||.

如果我写的东西象下面,它只是相匹配的存在与否&&不是||.

String inputTextFromFile = "This text contains double ampersand &&, and double pipe || and can this be recognised ? ";

Pattern pattern = Pattern.compile("(?=&&)(?= ||)");
Matcher matcher = pattern.matcher(inputTextFromFile);
Run Code Online (Sandbox Code Playgroud)

请让我知道我如何能够完全匹配&&||在输入文本中.

java regex lucene

2
推荐指数
1
解决办法
1683
查看次数

标签 统计

java ×1

lucene ×1

regex ×1