How to extract a part of the url through regular expression in textwrangler?

StackOverflow https://stackoverflow.com/questions/21849216

  •  13-10-2022
  •  | 
  •  

Вопрос

My work involves manipulating lots of data. I use textwrangler as text editor but I guess the things would remain the same on all text editors.

So I have a url

 http://example.com/swatches/frisk-watches/pr?p[]=sort%3Dpopularity&sid=812%2Cf13&offer=GsdOfferOnWatches07.&ref=4c83d65f-bfaf-4db6-b5f5-d733d7b1d2af

The above one is a sample url

I want to capture the text GsdOfferOnWatches07. i.e text from offer= and till &ref using regular expression on textwragler Ctrl+F feature.

How can I do that?

Это было полезно?

Решение

$link = 'http://example.com/swatches/frisk-watches/pr?p[]=sort%3Dpopularity&sid=812%2Cf13&offer=GsdOfferOnWatches07.&ref=4c83d65f-bfaf-4db6-b5f5-d733d7b1d2af';

preg_match('/offer=(.*?)&ref/', $link, $match);      
echo $match[1];'
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top