I-PHP.d Exercise PHP-RegExp
Emmanuel Benoist Home Page

Exercise PHP-Regular Expressions

Find an expression

Write a PHP program that counts the number of time your name occures in a document.
Solution
findName.php and (Sources)

Find and replace

Write a PHP program that transforms all occurences of www.hti.bfh.ch into www.ti.bfh.ch.
Solution
replaceBFHTI.php, Source where the original page is : testBFHTI.html.

A more complicated RegExp

Write the PHP program for changing any student address name.surname@hti.bfh.ch into kuerzel@bfh.ch. We suppose all users are students and have number 1, that means that the kuerzel is 4 first letters of the surname and the very first letter of the first name, plus number 1.
Solution
changeEmail.php, Source (with two regexp) or Source (with only one) where the original page is the same file: testBFHTI.html.