Internal Regex example added.

This commit is contained in:
Kolan Sh 2015-08-26 17:57:20 +03:00
parent 135577fee9
commit c69b3fa872
1 changed files with 20 additions and 0 deletions

20
vala/regexp/ex.vala Normal file
View File

@ -0,0 +1,20 @@
bool is_valid_email(string email) {
var status = true;
stdout.puts(@"$email is ");
if(! /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.match(email)) {
stdout.puts("not ");
status = false;
}
stdout.puts("valid email address.\n");
return status;
}
void main () {
is_valid_email("backbone@backbone.ws");
is_valid_email("abrakadabra@@@lksdfj");
var r = /(_name_|_NAME_|_Name_)/;
var s = r.replace("My name is _NAME_", -1, 0, "Kolan");
stdout.puts(@"$s\n");
}