Using RegEx this VB.NET code validates an email address. Menggunakan regex kode VB.NET memvalidasi alamat email. It's checking for a string separated by the at (@) character, and again separated by a dot. Ini memeriksa string dipisahkan oleh karakter (@) di, dan lagi dipisahkan oleh sebuah titik.
- Private Sub Button1_Click (ByVal Sebagai pengirim Sistem. Obyek, ByVal e Sebagai EventArgs Sistem.) Menangani Tombol1. Klik
- ' The regular expression rule 'Aturan ekspresi reguler
- Dim Expression As New System. Text . RegularExpressions . Regex ( "\S+@\S+\.\S+" ) Ekspresi Dim Sistem Baru. Teks. RegularExpressions. Regex ("\ S + @ \ S + \ \ S. +")
- ' If the email matches the regular expression 'Jika email cocok dengan ekspresi reguler
- If Expression. IsMatch ( "spamthis@geekpedia.com" ) Then Jika Ekspresi IsMatch ("spamthis@geekpedia.com"). Kemudian
- MessageBox. Show ( "The email address is valid." ) MessageBox Tampilkan ("Alamat email valid.").
- Else Lain
- MessageBox. Show ( "The email address is NOT valid." ) MessageBox Tampilkan ("Alamat email TIDAK valid.").
- End If End If
- End Sub End Sub
0 komentar:
Posting Komentar