2009-12-08 89 views

回答

6

好,这里是CFML答案:)

<cfset email = "[email protected]" /> 
<cfif ListLast(email, "@") EQ "google.com"> 
Horray! 
</cfif> 

编辑

专为Amarghosh。我们可以这样做,不用担心:

<cfscript> 
    email = "[email protected]"; 
    if (ListLast(email, "@") == "google.com") { 
     // here you go 
    } 
</cfscript> 
+0

用于回答正确的语言+1 - 顺便说一句,这是一个有趣的语法。 – Amarghosh 2009-12-08 16:14:24

+0

@Amarghosh有趣但很好! :) – Sergii 2009-12-08 16:22:06

1

如果您只是在寻找一个特定的域名,那么仅仅使用一些字符串操作可能会更容易。

我不知道的ColdFusion,但

addr.lastIndexOf("@google.com") 

一个类似于如果它不是-1,那么它从你正在寻找的域。

1
if(email.substring(email.indexOf("@") + 1) == "google.com") 
    print("valid"); 
1

你只是想比较一个电子邮件地址的域名?

listLast("[email protected]","@") IS "google.com" 

是一种方法。

相关问题