regex search and group

50 views Asked by At

Hi i want to use regular expression and search "MsRtcOAuth href=\" and fetch the value of "https://google.com\"

STRING= "Bearer trusted_issuers=\"\", client_id=\"00000004-0000-0ff1-ce00-000000000000\", MsRtcOAuth href=\"https://google.com\",grant_type=\"urn:microsoft.rtc:windows,urn:microsoft.rtc:anonmeeting,password\""

Please tell me how to do it in JavaScript. I have done this in Python using re. Example:

m=re.search('MsRtcOAuth href="(.*?)"', STRING) 

and get the result

m.group(1)="https://google.com\"
1

There are 1 answers

0
antonku On BEST ANSWER

You are probably looking for something like as follows:

const str = 'STRING= "Bearer trusted_issuers=\"\", client_id=\"00000004-0000-0ff1-ce00-000000000000\", MsRtcOAuth href=\"https://google.com\",grant_type=\"urn:microsoft.rtc:windows,urn:microsoft.rtc:anonmeeting,password\""';

console.log(str.match(/MsRtcOAuth href=\"(.*?)"/)[1]);