简体   繁体   中英

Regex - Select Link and everything before/after

With all the questions already asked on this topic unfortunately I was unable to combine all the information into a working Regex.

I'm trying to use yahoo pipes to substitute the content of an RSS post with a link that was previously contained in this post (HTML format).

Within the post there are various links but only one link with the url and parameter I am looking for. I'm trying to extract .txt and .pdf files, the expression for filetype is lazy because there are more links to pdf/txt files later on and I want only the first link to be selected (from what I understood, if I don't make it lazy the text up until the last occurence of the filetype will be selected).

The links are embedded as follows:

...Previous Link</a> – <a rel="nofollow" target="_blank" href="http://url.net/file/folder/filename.parameter.txt/pdf">description</a> – Next Link <a rel...

I need all Text before/after this link selected because I'm substituting the whole selection with the actual plain-text Link. What I've come up with so far is:

((.|\n)*)(http://url.*parameter.*?(txt|pdf))((.|\n)*)

It does work in Regexr: http://regexr.com/3argq But unfortunately results in the following error when put in yahoo pipes:

unable to complete regex operation

How should I proceed ahead?

您需要转义斜线-而不是//\\/\\/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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