Archive for March 7th, 2007

Using Regular Expressions

 
function transform(text) {
 
 text=text.replace(/é/gi,"e");
 text=text.replace(/(\bla\b)|(\ble\b)|(\bles\b)|(\bde\b)|(\bdes\b)|(\bdu\b)|(\ba\b)|(l')|(d')/gi,"");
 text=text.replace(/\//gi," ");
 
 return text;
}

3.) replaces the french character “é” with a “e” for all occurences
4.) delete some french words
5.) delete the special character slash with a space

For further information to the RegEx I recommend:

Regular_expression wiki