Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 匹配模式中的子字符串的正则表达式模式_Regex - Fatal编程技术网

Regex 匹配模式中的子字符串的正则表达式模式

Regex 匹配模式中的子字符串的正则表达式模式,regex,Regex,我有一个字符串日志文件,它有一个模式,我需要帮助获取正确的正则表达式来替换java中的模式 文件中的模式是 {\"KJ01\":{\"systemId\":\"ER\",\"authenticationChar\":\"adf72a0db2cbd364-62d3aa2.03eda_902f\",\"serialNo\":\"KJ01202004241755021736\" 我想换一个 authenticationChar\":\"adf72a0db2cbd364-62d3aa2.03eda_9

我有一个字符串日志文件,它有一个模式,我需要帮助获取正确的正则表达式来替换java中的模式

文件中的模式是

{\"KJ01\":{\"systemId\":\"ER\",\"authenticationChar\":\"adf72a0db2cbd364-62d3aa2.03eda_902f\",\"serialNo\":\"KJ01202004241755021736\"
我想换一个

authenticationChar\":\"adf72a0db2cbd364-62d3aa2.03eda_902f\"
authenticationChar\:\“xxx”

因此,基本上我试图在日志中屏蔽authenticationChar

它可能包含的特殊字符是-_\

我一直在尝试各种正则表达式,但我总是遇到语法异常

我的一次尝试是:

content = content.replaceAll("(authenticationChar\\\":\\\")([ ]*[0-9A-Za-z-._\\]*[ ]*)*", "(authenticationChar\\\":\\\"xxx");
但这并不奏效 有人能帮我吗?

试试这个:


content=content.replaceAll((?谢谢@kishkin,但我在索引32附近得到了一个
java.util.regex.PatternSyntaxException:Unclosed character类(?更新,但不确定:)现在,非常确定:另一个修复。当然。我明天再试一次,让你知道。谢谢@kishkin