0

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?

Sulejmani
  • 11
  • 2
  • 12

1 Answers1

1

Use negative lookahead to remove {4 which are followed by :. Also remove square brackets as they will match all of the results individually.

{4(?!:)

DEMO

  1. {4 matches the characters {4 literally
  2. (?!:) is negative lookahead which means look for {4 which are not followed by :
Raman Sahasi
  • 30,180
  • 9
  • 58
  • 71