Search code examples
javascriptregexextjsextjs4

How to find trailing commas in javascript ExtJs or AngularJs code


I need to find trailing commas in my code if any for example:

id:"1",
name:"myComponent",
onClick:"someFunction",
listner:"someListner",

Now the last trailing comma in listener fails my ExtJS 4.2.2 script in IE 8. Is there a way or any regular expression to find such trailing commas.


Solution

  • Open notepad ++ and in find menu select regular expression check box and use following regex

    ,\s*\n+(\s*\/\/.*\n)*\s*[\}\)\]]
    

    Hope this helps