This question already has answers here:
Regular expression to stop at first match
(9 answers)
Closed 1 year ago.
I have the following text:
Some text
{\"url\": \"https:\/\/www.someurl.com\/200x200\/fsdffsde3e", \"bbb\"} kljkl
{\"url\": \"https:\/\/www.someurl.com\/500x500\/fsdffsde3e", \"bbb\"} kljkl
Some text
I want to extract all the URLs contains 200x200. so for example I need this URL: https:\/\/www.someurl.com\/200x200\/fsdffsde3e
this, will bring the entire row: "https(.*?)200x200(.*)" but I want only the URL.
Have a look: https://regex101.com/r/DDWLDM/1
Thanks
use This exp
"https(.*?)200x200(.*?)"
Related
This question already has answers here:
How can I delete a query string parameter in JavaScript?
(27 answers)
Closed 5 years ago.
On the following string I want to remove sort=*. I can get this done by run loop over it But want to get it done using regex which is new to me.
So start point should be "sort" and end point should be '&' and sort value could be *
I have created this one but dont how to add end point
string.replace((sort=*)\w,'')
"category_id=249&sort=name&category_filter=15&"
to
"category_id=249&category_filter=15&"
You ca use this regex instead (sort=.*?&), which can match every thing from sort= until the first occurrence of &
regex demo
Output
category_id=249&category_filter=15&
This question already has answers here:
Regular expression to get a string between two strings in Javascript
(13 answers)
Closed 4 years ago.
I am trying to get the text between the two tags which also handles multiple lines.I have managed to do it in PHP regex but i am stuck on the javascript one.
<any_tag>random text
dffdffdfdfdfdfdfdfd
dfdfdfdfdfdfdfdfdf
</any_tag>
I want to get the text between <any_tag> and </any_tag>
This is the regex for php
https://regex101.com/r/tQ1bX7/2
Now i am trying to achieve to same in javascript
Give try on following :
/[^(<any_tag>)](?:.*(\r?\n?).*)*(?=\<\/any_tag\>)/gi
Explination :
[^(<any_tag>)] match a single character not present in the list below
(<any_tag>) a single character in the list (<any_tg>) literally (case insensitive)
This question already has answers here:
Regular Expression to find a string included between two characters while EXCLUDING the delimiters
(13 answers)
Closed 7 years ago.
An API I use returns this text:
<http://192.168.1.10:8080/longUrl>; rel="recording-session",
<http://192.168.1.10:8080/realLongUrl>; rel="h264-session-sdp",
<http://192.168.1.10:8080/realLongDifferentUrl>; rel="h264-session-sdp",
<rtp://239.1.1.18:5006>; rel="destination-high",
<rtp://239.1.1.17:5006>; rel="destination-low"
I'm trying to retrieve the first URL that is followed by ; rel="h264-session-sdp.
So in this case that would be: http://192.168.1.10:8080/realLongUrl
I've been fiddling around trying to modify examples found here on SO, but just can's seem to get it right.
try this one /([^<]+)(?:>; rel\=\"h264\-session\-sdp\")/
Selects the text inbetween the greater then and less then characters:
?<=\<)(.*?)(?=>)
https://regex101.com/r/oS5sX6/1
And if you wanted to select the urls on multiple lines, add the g and m modifiers:
/(?<=\<)(.*?)(?=>)/gm
https://regex101.com/r/oS5sX6/2
Try this:
/(?<=\<)(.*?)(?=\>)>; rel="h264-session-sdp"/
This question already has answers here:
How to remove text from a string?
(16 answers)
Closed 7 years ago.
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
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
This question already has answers here:
How to get URL parameter using jQuery or plain JavaScript?
(34 answers)
Closed 7 years ago.
I am trying to get an id from a url string generated in php depending on the page you are viewing the id can appear in different places for example
site.com/view.php?id=12&person=23
or
site.com/view.php?loc=man&id=1782&person=43
I just need to get the id section using JQuery any ideas
You can use regex to get the id from URL.
var id = url.match(/id=(\d+)/)[1]
DEMO
REGEX Explanation
/: Delimiters of regex
id=: Matches literal id=
() : Capturing group
\d+: Matches one or more numbers