pmirnd pmirnd - 1 year ago 115
JSON Question

Regex javascript exclude one character

I need to find this string:

{ "any string but :",

for example:

{ id,
{ this.content,
{ var = {123},

I'm searching it on Notepad++ with:

{ (.*?),

But I don't know how to exclude the : with


Any help? thanks.

Undesire results:

{ id:id,

I'm searching for a javascript syntax error. By mistake, someone has defined JSONS as:

{ id, data, etc, etc,...}

When they have to be (this is the correct way):

{ id: id, data: something, etc:etc, etc:something,...}

So I want to find where that string doesn't have the : (which is correct)

Answer Source

You could use something like this:


Working demo

Update: I noticed you updated your question. So, for your edited question you can use:

{[^:]*?,|(?<=, )\w+,

Working demo 2

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download