Home > Enterprise >  Fix unnecessary script with regex
Fix unnecessary script with regex

Time:09-17

I'm using vscode to replace some unnecessary script

for exmaple

Transform it

$('#tData').removeAttr('disabled');
$('#tCliente').removeAttr('disabled');
$('#tProduto').removeAttr('disabled');
$('#bAcessarRegistro').removeAttr('disabled');

to

$(`#tData
    ,#tCliente
    ,#tProduto
    ,#bAcessarRegistro`).removeAttr('disabled');

With regex replace ?

CodePudding user response:

https://regex101.com/r/bBtOyq/2

Find all but last

').removeAttr('disabled');
$('

and replace with , or ,\n

Here is the find part

/'\)\.removeAttr\('disabled'\);((\s )?\$\(')?(?=.*?\))/

CodePudding user response:

select ').removeAttr('disabled'); $('

press Ctrl D as often as needed

press Enter Spaces or TAB and ,

  • Related