2009-12-08 42 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" 

是一種方法。

相關問題