在正则表达式中删除
Deletion in a regex
我会把这个问题拆分成对我来说更容易的 :
对于这个表达式:
"created":"589c8377576a33706397f3f4"
我写了这个正则表达式:
output_row.json.replaceAll("\"created\":\"589c8377576a33706397f3f4\"","");
有效!现在我想使用动态令牌,例如[[:xdigit:]]
.
我试过了,但没用!
output_row.json.replaceAll("\"created\":\"[[:xdigit:]]\"","");
你能给我一些建议吗?
[[:xdigit:]]
恰好是一个十六进制数字。添加 +
量词以匹配 1 到 n,或添加 *
以匹配 0 到 n 十六进制数字。
终于找到答案了:
//replace the value of the key created
output_row.json = output_row.json.replaceAll("\"created\":\"[a-zA-Z0-9]+\"","\"created\":\"" + formatted + "\"");
我不知道为什么这个 class 在 Talend 编辑器中不被接受:[[:xdigit:]]
也许不是特定于 Java?
无论如何,这个话题对我来说已经结束了!
麦酒
我会把这个问题拆分成对我来说更容易的 :
对于这个表达式:
"created":"589c8377576a33706397f3f4"
我写了这个正则表达式:
output_row.json.replaceAll("\"created\":\"589c8377576a33706397f3f4\"","");
有效!现在我想使用动态令牌,例如[[:xdigit:]]
.
我试过了,但没用!
output_row.json.replaceAll("\"created\":\"[[:xdigit:]]\"","");
你能给我一些建议吗?
[[:xdigit:]]
恰好是一个十六进制数字。添加 +
量词以匹配 1 到 n,或添加 *
以匹配 0 到 n 十六进制数字。
终于找到答案了:
//replace the value of the key created
output_row.json = output_row.json.replaceAll("\"created\":\"[a-zA-Z0-9]+\"","\"created\":\"" + formatted + "\"");
我不知道为什么这个 class 在 Talend 编辑器中不被接受:[[:xdigit:]]
也许不是特定于 Java?
无论如何,这个话题对我来说已经结束了!
麦酒