I have a file with following information
Hi my {4 name is {4: Jeremy I {4: work in {4 Texas My job is {3 very {0 hard, I work until 4
I need to match all {4 values in this text, so I tried to write following regex: [\{4^:]
But when I try this on a regex tester, it matches all occurances of {, 4 and : but I only want the combination of {4 without a : in it.
What am I doing wrong?
{4not followed with:, useString res = s.replaceAll("\\{4(?!:)", "newValue");. If you need to replace all{4, just use.replace("{4", "NEW_VALUE")- no need for a regex.[...](character class).replace("{4:", "<NEWVAL>:").