Hello all,

Wondering if someone can direct me to a regex component and some code that I can use to strip out certain links from an HTML file (loading in a StringList).


Example:

<a href="../foo/23134.htm">bar</a>

The result I'm after is:

bar

I only want to strip the link here, but not all links from the page, only ones that contain the ../foo directory in their link. Also, the text within the link needs to stay.

Thanks.

I guess you didnt download their studio product to test your regex code on..

I guess you didnt download their studio product to test your regex code on..

Ok I'll concede the point. I didn't give the "studio" thing a fair shake. I'm not sure (still) how I managed this but here's the working regex:

<a href="../killthislink/([^>]*?)>(.*?)</a>

Regex is a simple but powerful tool. Once you grasp the meaning of bits, it will be very useful and in delphi its one of the fastest methods of searching for non specific text

Regex is a simple but powerful tool. Once you grasp the meaning of bits, it will be very useful and in delphi its one of the fastest methods of searching for non specific text

Well I appreciate the help LizR, I can tell that I need to become fluent in this syntax, as you stated it has many applications.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.