1

I want to find text like },1{ },12{ and replace this with },{.

I need regular expression to match word like },digit{.

I have tried this but its not matching exactly:

[^\}][^\,][^\d][^\{]

Omi
  • 3,954
  • 5
  • 21
  • 41

2 Answers2

2

Here is one way to do this using lookarounds. Try the following find and replace in regex mode:

Find:    (?<=\},)\d+(?=\{)
Replace: (leave empty)

This regex targets one or more digits positioned as you described, and then replaces them with nothing, effectively removing them.

Demo

Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
1

Try this \},\d+\{ replace with },{ as mentioned.

Should match for },{ exactly and any digits in between

This is faster than lookahead and takes fewer steps (13)

Demo: [ https://regex101.com/r/ciKbse/1 ]

as compared to 49 with lookaheads (?<=\},)\d+(?=\{) [ https://regex101.com/r/cqlHCo/1 ]

Dhananjai Pai
  • 5,914
  • 1
  • 10
  • 25