在字符串中查找@和其他项目 [英] Finding @ in a string, and other items
本文介绍了在字符串中查找@和其他项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的 - 我想在其中检查@的字符串(我正在检查一个字符串
应该包含一封电子邮件是否包含@)
我该如何解决这个问题?的preg_match?额日格? strstr?例子?
另外 - 我怎样才能在字符串中找到任何非字母数字字符,所以我可以给用户一个错误信息。我不想在字符串中除了
字母数字之外还有任何字符。
解决方案
使用regexp最简单处理这类事情。
preg_match(''/ ^ [\\\\。] + @ \ w + \。\ w + /'',
<
Uzytkownik" Picture Dots" <我们******* @ brimstonedragons.com> napisal w
wiadomosci新闻:HQ ***************** @ fe1.columbus.rr.com ...
好的 - 我想在其中检查@的字符串(我正在检查是否应该包含一封电子邮件的字符串
包含@)
我该如何解决这个问题?的preg_match?额日格? strstr?示例?
另外 - 如何在字符串中找到任何非字母数字字符,以便我可以向用户提供错误消息。我不想在字符串中除了
字母数字之外还有任何字符。
我注意到Message-ID:< wo ********************@comcast.com>来自
Chung Leong包含以下内容:
使用正则表达式来处理这类事情最简单。
preg_match(' '/ ^ [\w\。] + @ \w + \.\w + /',
Ok - I want to check a string for @ in it (Im checking to see if a string
that should contain an email holds a @ )
How would I go about this? preg_match? ereg? strstr?Examples?
Also - how would I find any non alpha numeric characters in a string so I
can give the user an error message. I dont want any characters besides
alpha-numeric in the strings.解决方案It''s easiest to use regexp to deal with this sort of thing.
preg_match(''/^[\w\.]+@\w+\.\w+/'',
address) should do the trick.
Uzytkownik "Picture Dots" <we*******@brimstonedragons.com> napisal w
wiadomosci news:HQ*****************@fe1.columbus.rr.com...Ok - I want to check a string for @ in it (Im checking to see if a string
that should contain an email holds a @ )
How would I go about this? preg_match? ereg? strstr?Examples?
Also - how would I find any non alpha numeric characters in a string so I
can give the user an error message. I dont want any characters besides
alpha-numeric in the strings.
I noticed that Message-ID: <wo********************@comcast.com> from
Chung Leong contained the following:
It''s easiest to use regexp to deal with this sort of thing.
preg_match(''/^[\w\.]+@\w+\.\w+/'',
这篇关于在字符串中查找@和其他项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文