简体   繁体   English

字符串的PHP Regex降价

[英]PHP Regex markdown from string

I have this string: " Download it from [http://wordpress.org/extend/plugins/wordpress-mobile-admin/](http://wordpress.org/extend/plugins/wordpress-mobile-admin/) "; 我有这个字符串:“ Download it from [http://wordpress.org/extend/plugins/wordpress-mobile-admin/](http://wordpress.org/extend/plugins/wordpress-mobile-admin/) ” ;

And i'm trying to convert this markdown to actual HTML, i tried getting the matches like so: 我正在尝试将此降价转换为实际的HTML,我尝试像这样获取匹配项:

preg_match_all('/[(.*?)]((.*?))/', $data[$toProcess], $links);
debug($links);

Yet this..did not work. 然而,这没有用。

Can anyone point me in the right direction to convert this markdown into HTML. 任何人都可以向我指出正确的方向,以将此降价转换为HTML。

ps. PS。 i'd rather not import the whole markdown library. 我宁愿不导入整个markdown库。

您需要转义[]()因为它们都是正则表达式元字符:

preg_match_all('/\[(.*?)\]\((.*?)\)/', $data[$toProcess], $links);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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