-2

In JavaScript, I need to find a substring between &J= and Key using regex and remove it from my url which could contain several substrings.

Here is my url:

SID=18608202881669&Act=432&Mode=1&CLk=T&Key58=6003&dotnetdll=TopCoConfigurator.dll&dotnetfunc=CasingSizeSummary&SID=18608202881669&F=&J=CasingSize/CasingSizeSummary.asp&Key58=6003&ccs_casingsizeid=6003

Thanks

hwnd
  • 69,796
  • 4
  • 95
  • 132
Ben J
  • 37
  • 3

1 Answers1

0

You can learn Regular Expression here and code for your problem is: Here you go:

    SID="18608202881669&Act=432&Mode=1&CLk=T&Key58=6003&dotnetdll=TopCoConfigurator.dll&dotnetfunc=CasingSizeSummary&SID=18608202881669&F=&J=CasingSize/CasingSizeSummary.asp&Key58=6003&ccs_casingsizeid=6003";

var re = /&J=(.*?)&Key/;
SID = SID.replace(re, '');
alert(SID);

See Fiddle

Imran
  • 1,094
  • 1
  • 21
  • 41