正则表达式 [英] regular expression

查看:142
本文介绍了正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




不是很擅长php正则表达式,任何人都可以帮我给

正则表达式:

- 一个电子邮件地址,

- 一个网站地址(如果可能的话包括子域名)。


非常感谢提前,
-

nyso

解决方案

nyso写道:

不是非常擅长php正则表达式,任何人都可以帮我提供
正则表达式:
- 一个电子邮件地址,
- 一个网站地址(如果可能,包括子域)。




这些是原始的,但对我有用:

//替换不在锚标签中的URL


图案= ''/(HTTP:\ / \ / [^ \s\" \)LT;>] +)/ I '';


//获取要链接的电子邮件地址


pattern =''/([az] [a-z0-9 _.- \ /] * @ [^ \ s \" \)\?<>] +)/ i'';


这些是与preg_ *函数一起使用的模式


-

Justin Koivisto - sp**@koivi.com

PHP海报:请使用comp.lang.php获取与PHP相关的问题,

alt.php *不推荐使用组。


Hi,

being not very good at php regular expression, could anyone help me giving
the regular expression for :
- an e-mail address,
- a website address (including sub-domain if possible).

many thanks in advance,
--
nyso

解决方案

nyso wrote:

being not very good at php regular expression, could anyone help me giving
the regular expression for :
- an e-mail address,
- a website address (including sub-domain if possible).



These are primitive, but have worked for me:
// replace URLs that aren''t in an anchor tag


pattern=''/(http:\/\/[^\s\"\)<>]+)/i'';

// get email addresses to link


pattern=''/([a-z][a-z0-9_.-\/]*@[^\s\"\)\?<>]+)/i'';

These are patterns that are used with the preg_* functions

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.


这篇关于正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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