You get a bonus - 1 coin for daily activity. Now you have 1 coin

Verbal expressions instead of regular ones invariably simplify coding in PHP and Javascript

Practice




Verbal expressions instead of regular ones invariably simplify coding in PHP and Javascript

to make regular expressions simpler you can use an interesting class

http://thechangelog.com/stop-writing-regular-expressions-express-them-with-verbal-expressions/

and write them like this


$regex = new VerbalExpressions;

var tester = VerEx()
.startOfLine()
.then( "http" )
.maybe( "s" )
.then( "://" )
.maybe( "www." )
.anythingBut( " " )
.endOfLine();

if($regex->test("http://my-city.com.ua"))
echo "this is a url";
else
echo "invalid url";



if (preg_match($regex, 'http://github.com')) {
echo 'this is a url';
} else {
echo 'invalid url';
}


https://github.com/VerbalExpressions/PHPVerbalExpressions

for javascript

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Scripting client side JavaScript, jqvery, BackBone"

Terms: Scripting client side JavaScript, jqvery, BackBone