如何在Delphi中实现一组标准的超链接检测规则 [英] How Can I Implement A Standard Set of Hyperlink Detection Rules in Delphi

查看:147
本文介绍了如何在Delphi中实现一组标准的超链接检测规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在程序中自动检测文本中的超链接。我做得很简单,只查找 http:// www。

I currently do automatic detection of hyperlinks within text in my program. I made it very simple and only look for http:// or www.

但是,用户建议我把它扩展到其他形式,例如: https:// .com

However, a user suggested to me that I extend it to other forms, e.g.: https:// or .com

然后我意识到它可能不会停在那里因为有ftp和mailto和文件,所有其他顶级域名,甚至电子邮件地址和文件路径。

Then I realized it might not stop there because there's ftp and mailto and file, all the other top level domains, and even email addresses and file paths.

我认为最好的方法是通过遵循当前使用的一些常用的标准超链接检测规则集来限制它。也许Microsoft Word是如何做到的,或者RichEdit是如何做到的,或者你知道更好的标准。

What I think is best is to limit it to what is practical by following some often-used standard set of hyperlink detection rules that are currently in use. Maybe how Microsoft Word does it, or maybe how RichEdit does it or maybe you know of a better standard.

所以我的问题是:

是否有内置函数可以从Delphi调用来进行检测,如果有,那么调用会是什么样的? (我计划将来去FireMonkey,所以我更喜欢能在Windows之外运行的东西。)

Is there a built in function that I can call from Delphi to do the detection, and if so, what would the call look like? (I plan in the future to go to FireMonkey, so I would prefer something that will work beyond Windows.)

如果没有可用的功能,是否有一些功能我可以找到一组记录在Word,RichEdit中检测到的内容的规则,或者应该检测到的任何其他规则集?那将允许我自己编写检测代码。

If there isn't a function available, is there some place I can find a documented set of rules of what is detected in Word, in RichEdit, or any other set of rules of what should be detected? That would then allow me to write the detection code myself.

推荐答案

尝试 PathIsURL 功能,在中声明ShLwApi 单位。

这篇关于如何在Delphi中实现一组标准的超链接检测规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆