regex - string.search (".") 总是返回 0

标签 regex apache-flex actionscript-3 flashbuilder4

我在 Flash Builder 4 工作。 在 Flex 上创建电子邮件验证器。 有这个代码

    public var s:String="";

    public function checkSumbols(_s:String=""):Boolean {

        s=_s;  //e-mail address (input mail@supermail.com)

        var hDog:int=0; 
        var hPoint:int=0;
        //check @
        hDog=s.search("@");
        trace(hDog)  // It's work
        if(hDog==-1) {
            return false;
        } else {
            hPoint=s.substr(hDog).search(".");
            trace(hPoint); // PANIC this return always 0
            if(hPoint==-1){
               return false;
        }}
    }

最佳答案

您可以使用正则表达式。由于点 (.) 在正则表达式中具有特殊含义,因此您需要在前面加上“转义”字符:yourString.search(/\./); 应该管用。 HTH 金融时报

关于regex - string.search (".") 总是返回 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4574675/

相关文章:

apache-flex - git + Flash Builder 工作流程 : how do I set it up so git works smoothly?

apache-flex - Spark.components.List 的多行 itemRenderer - 带有测试用例和屏幕截图

actionscript-3 - Flash AS3 中的文本链接

actionscript-3 - 检查 ActionScript 中的字符串是否为空,类似于 .net 中的 String.Empty

php - 正则表达式 preg qoute 模仿正则表达式

java - 使用Java和正则表达式来修复路径

java - 从java文本文件中提取包含2个单词的句子

python random.sample ("abc",3) 。如何使用正则表达式代替 "abc"

apache-flex - 是否可以在 Flex 中执行轻量级 REST 调用?

javascript - ExternalInterface.call 在 IE 中不返回对象