web:php:regex:example
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
web:php:regex:example [le 10/10/2013 à 13:26] – créée Yosko | web:php:regex:example [le 17/02/2015 à 16:47] (Version actuelle) – Yosko | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Exemples de regex en vrac ====== | ====== Exemples de regex en vrac ====== | ||
- | | + | Quelques exemples d' |
- | // 2- removes escaped ' and " | + | |
- | // 3- removes content betweend '' | + | <code php> |
- | $embracerPattern = "/ | + | // 1- remove recursively the content of for (), [] and {} |
- | $escapedQuotePattern = "/ | + | // 2- removes escaped ' and " |
- | $quotedStringPattern = "/' | + | // 3- removes content betweend '' |
+ | $embracerPattern = "/ | ||
+ | $escapedQuotePattern = "/ | ||
+ | $quotedStringPattern = "/' | ||
+ | |||
+ | //replace escaped quotes with html entities | ||
+ | $escapedQuotePattern = "/ | ||
+ | $call[' | ||
+ | $escapedQuotePattern = "/ | ||
+ | $call[' | ||
+ | |||
+ | //replace commas between remaining (double) quotes with html entities | ||
+ | $quotedStringPattern = "/' | ||
+ | $call[' | ||
+ | $quotedStringPattern, | ||
+ | function ($matches) { | ||
+ | return str_replace(',','&# | ||
+ | }, | ||
+ | $call[' | ||
+ | ); | ||
+ | |||
+ | //replace commas between parentheses, | ||
+ | $embracerPattern = "/ | ||
+ | $call[' | ||
+ | |||
+ | //get the list of given parameters | ||
+ | $results = preg_split('/,/', | ||
+ | </ |
web/php/regex/example.1381411613.txt.gz · Dernière modification : le 10/10/2013 à 13:26 de Yosko