Anonymous Human
Anonymous Human

Reputation: 1948

Sublime text regular expression search and replace

Using Sublime Text 3, I have a text file with many lines like this:

{"Currency" : "Andorran Franc","Code" : "ADF","USD/1 Unit" : "0.1853","Units/1 USD" : "5.3967"}
{"Currency" : "Andorran Peseta","Code" : "ADP","USD/1 Unit" : "0.007306","Units/1 USD" : "136.8890"}

For each line I would like to eliminate the "Currency" field and its value so that the lines look like:

{"Code" : "ADF","USD/1 Unit" : "0.1853","Units/1 USD" : "5.3967"}
{"Code" : "ADP","USD/1 Unit" : "0.007306","Units/1 USD" : "136.8890"}

but I have having trouble coming up with a regular expression to apply.

Upvotes: 0

Views: 524

Answers (2)

vks
vks

Reputation: 67988

"Currency"[^,]*,

Try this.Replace by empty string.See demo.

https://regex101.com/r/tX2bH4/13

If the format is fixed then it can be done in this simple way

Upvotes: 0

Avinash Raj
Avinash Raj

Reputation: 174874

Use the below regex and then replace the matched chars with an empty string.

"Currency"\s*:\s*"[^"]*",

OR

"Currency"\s*:.*?,(?="[^"]*"\s*:)

DEMO

Upvotes: 1

Related Questions