cfm 5 email 正則式: (兩個是一樣的)
<cfset reg = "[[:alnum:]]+([-+.’][a-zA-Z0-9]+)*@[a-zA-Z0-9]+([-+.’][[:alpha:]]+)*\.[[:alpha:]]{2,}([-+.’][[:alpha:]]+)*" >
<cfset reg = "[[:alnum:]]+([-+.’][[:alnum:]]+)*@[[:alnum:]]+([-+.’][[:alpha:]]+)*\.[[:alpha:]]{2,}([-+.’][[:alpha:]]+)*" >
<!---檢查email規則--單筆--->
<cfset find1 = REFind( reg , form.m_email ,1 ,"true") >
<cfset tmpEmail = "">
<cfif find1.pos[1] gt 0>
<cfif tmpEmail neq form.m_email>
<cfset reg = "[[:alnum:]]+([-+.’][[:alnum:]]+)*@[[:alnum:]]+([-+.’][[:alpha:]]+)*\.[[:alpha:]]{2,}([-+.’][[:alpha:]]+)*" >
<!---檢查email規則--單筆--->
<cfset find1 = REFind( reg , form.m_email ,1 ,"true") >
<cfset tmpEmail = "">
<cfif find1.pos[1] gt 0>
<cfset tmpEmail = Mid(form.m_email,find1.pos[1],find1.Len[1])></cfif>
<cfif tmpEmail neq form.m_email>
<cfset msg = msg & "「我的電子郵件」欄位格式錯誤,請重新輸入\n" ></cfif>
<!---檢查email規則--多筆--->
<cfloop index="j" from="1" to="#listlen(form.f_email,';')#" >
<cfset find2 = REFind( reg , listgetat(form.f_email,j,";"),1,"true") >
<cfset tmpEmail = "">
<cfif find2.pos[1] gt 0>
</cfloop><cfset tmpEmail = Mid(form.f_email,find1.pos[1],find2.Len[1])></cfif>
<cfif tmpEmail neq form.email>
<cfset msg = msg & "「朋友的電子郵件」欄位,email:"& listgetat(f_email,j,";") &"格式錯誤,請重新輸入\n" ></cfif>
cfm mx email 正則式:
<cfset reg = "\w+([-+.’]\w+)*@\w+([-.]\w+)*\.\w{2,}([-.]\w+)*" ><!---跟js相同--->
<cfset email = "aaa@aaa.aaa.aaa">
<cfset find1a = REFind( reg , email ) >
<cfoutput>#find1a#</cfoutput>
<cfabort>
<cfset email = "aaa@aaa.aaa.aaa">
<cfset find1a = REFind( reg , email ) >
<cfoutput>#find1a#</cfoutput>
<cfabort>
沒有留言:
張貼留言