var text = 'abc.def';var pattern = /^[a-z]+([\.\-]?[a-z]+)?$/;if (text.match(pattern)) { print("YES!");} else { print("NO!");}
Standard input is empty
YES!
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!