-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

4
  • 2
    What have you tried so far? SO is not "can someone please write a regex for me". Commented Aug 11, 2015 at 6:45
  • Why must it use a regular expression? Commented Aug 11, 2015 at 6:45
  • use javascript replace() function for strings Commented Aug 11, 2015 at 6:48
  • You should try this to find all substrings b/w &J= and Key / (?<=\S)&(.*?)(?=Key) /g Commented Aug 11, 2015 at 7:26

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.