简体   繁体   English

如何通过textwrangler中的正则表达式提取网址的一部分?

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

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. 我使用textwrangler作为文本编辑器,但我想所有文本编辑器上的内容都是一样的。

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. 我想捕获文本GsdOfferOnWatches07。 ie text from offer= and till &ref using regular expression on textwragler Ctrl+F feature. 即来自offer =和until&ref的文本在textwragler Ctrl + F功能上使用正则表达式。

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 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM