📄 725439.xml
字号:
<?xml version='1.0' encoding='GB2312'?>
<?xml-stylesheet type='text/xsl' href='../csdn.xsl'?>
<Topic>
<Issue>
<PostUserNickName>雨</PostUserNickName>
<rank>二级(初级)</rank>
<ranknum>user2</ranknum>
<credit>100</credit>
<TopicId>725439</TopicId>
<TopicName>JSP中email格式的判断</TopicName>
<PostUserId>209311</PostUserId>
<PostUserName>rain_ok</PostUserName>
<RoomName>JSP</RoomName>
<ReplyNum>5</ReplyNum>
<PostDateTime>2002-5-15 21:45:52</PostDateTime>
<Point>20</Point>
<ReadNum>0</ReadNum>
<RoomId>28</RoomId>
<EndState>2</EndState>
<Content>请问怎样才可以判断email的格式,就是判断有@符号,我用过
if(mail.indexOf('@')<=0)
   out.println("email address wrong!");
但是不可以,还有就是咋可以让它限制用户注册时在email栏输入中文,小妹谢谢各位了
</Content>
</Issue>
<Replys>
<Reply>
<PostUserNickName>巨海</PostUserNickName>
<rank>四级(中级)</rank>
<ranknum>user4</ranknum>
<credit>100</credit>
<ReplyID>4737203</ReplyID>
<TopicID>725439</TopicID>
<PostUserId>125624</PostUserId>
<PostUserName>Broadsea</PostUserName>
<Point>0</Point>
<Content>没这么简单,java.sun.com上有标准的例程,如果需要的话,可以帮你找找。</Content>
<PostDateTime>2002-5-16 9:05:58</PostDateTime>
</Reply>
<Reply>
<PostUserNickName>巨海</PostUserNickName>
<rank>四级(中级)</rank>
<ranknum>user4</ranknum>
<credit>100</credit>
<ReplyID>4737611</ReplyID>
<TopicID>725439</TopicID>
<PostUserId>125624</PostUserId>
<PostUserName>Broadsea</PostUserName>
<Point>10</Point>
<Content>找到了!我自己的EMIAL校验就是参照SUN下面的例子做的。
Email Validation 
The following code is a sample of some characters you can check are in an email address, or should not be in an email address. It is not a complete email validation program that checks for all possible email scenarios, but can be added to as needed. 
/*
* Checks for invalid characters
* in email addresses
*/
public class EmailValidation {
   public static void main(String[] args) 
                                 throws Exception {
                                 
      String input = "@sun.com";
      //Checks for email addresses starting with
      //inappropriate symbols like dots or @ signs.
      Pattern p = Pattern.compile("^\\.|^\\@");
      Matcher m = p.matcher(input);
      if (m.find())
         System.err.println("Email addresses don't start" +
                            " with dots or @ signs.");
      //Checks for email addresses that start with
      //www. and prints a message if it does.
      p = Pattern.compile("^www\\.");
      m = p.matcher(input);
      if (m.find()) {
        System.out.println("Email addresses don't start" +
                " with \"www.\", only web pages do.");
      }
      p = Pattern.compile("[^A-Za-z0-9\\.\\@_\\-~#]+");
      m = p.matcher(input);
      StringBuffer sb = new StringBuffer();
      boolean result = m.find();
      boolean deletedIllegalChars = false;
      while(result) {
         deletedIllegalChars = true;
         m.appendReplacement(sb, "");
         result = m.find();
      }
      // Add the last segment of input to the new String
      m.appendTail(sb);
      input = sb.toString();
      if (deletedIllegalChars) {
         System.out.println("It contained incorrect characters" +
                           " , such as spaces or commas.");
      }
   }
}</Content>
<PostDateTime>2002-5-16 9:24:38</PostDateTime>
</Reply>
<Reply>
<PostUserNickName>晓彬</PostUserNickName>
<rank>两星(中级)</rank>
<ranknum>star2</ranknum>
<credit>135</credit>
<ReplyID>4737741</ReplyID>
<TopicID>725439</TopicID>
<PostUserId>173450</PostUserId>
<PostUserName>Andrawu</PostUserName>
<Point>5</Point>
<Content>此帖里有你想要的判断email的格式的方法。
http://www.csdn.net/expert/topic/654/654432.xml?temp=.3112146</Content>
<PostDateTime>2002-5-16 9:29:38</PostDateTime>
</Reply>
<Reply>
<PostUserNickName>想说放弃不容易!!</PostUserNickName>
<rank>二级(初级)</rank>
<ranknum>user2</ranknum>
<credit>100</credit>
<ReplyID>4737761</ReplyID>
<TopicID>725439</TopicID>
<PostUserId>71192</PostUserId>
<PostUserName>HuangBin</PostUserName>
<Point>5</Point>
<Content>我给你个简单的:
 public boolean isEmail(String email){
    int pos;
    pos=email.indexOf('@');
    if (pos==-1)
       return false;
    else{
       pos=email.indexOf('.');
       if (pos==-1)
          return false;
       else
          return true;
    }
  }</Content>
<PostDateTime>2002-5-16 9:30:25</PostDateTime>
</Reply>
<Reply>
<PostUserNickName>阿峰</PostUserNickName>
<rank>二级(初级)</rank>
<ranknum>user2</ranknum>
<credit>100</credit>
<ReplyID>4738741</ReplyID>
<TopicID>725439</TopicID>
<PostUserId>85055</PostUserId>
<PostUserName>donny2000</PostUserName>
<Point>0</Point>
<Content>用正则表达式</Content>
<PostDateTime>2002-5-16 10:12:59</PostDateTime>
</Reply>
</Replys>
</Topic>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -