regex libs - sinsunsan/archiref_wiki GitHub Wiki
To test and collect regex https://www.regex101.com/#
- \s any white space
[a-zA-Z0-9-_\\\s]*
- ^ at the beginning of [] mean the opposite (not one of those chars)
- a-z char from a to z
- A-Z idem but in upper case
-
- the - char
- _ the _ char
- . the . char
- \ mean the \ char
[^a-zA-Z0-9-_\\.]
(?<=^|(?<=[^a-zA-Z0-9-_\\.]))@([A-Za-z]+[A-Za-z0-9_]+)
http://shahmirj.com/blog/extracting-twitter-usertags-using-regex
/\B#\w*[a-zA-Z]+\w*/
http://erictarn.com/post/1060722347/the-best-twitter-hashtag-regular-expression
if (preg_match('@^(?:http://)?([^/]+)(\/swf\/)([^/]+)@i', $params['source'] , $matches)) {
$params['id'] = $matches[3];
}
@dai\.ly/([^\?"\&]+)@i
le . est échappé grace à \
preg_match('#href#', $string1 , $matches);
preg_match('#^<a href="|a>$#', $string1 , $matches);
#bor?is# Boris avec 1 r ou 2
Le html du lien à analyser
<a href="http://dev.v2.seb.dev89.com:8080/2012/04/06/le-bobo-repoussoir-de-la-droite-puis-ennemi-prefere-de-le-pen-230350#comment-3005312" class="title"> Le « bobo », repoussoir de la droite puis ennemi préféré de Le Pen </a>
La regex
preg_match('@^<a href="([^"]*)(#comment-)(\d+)@i', $string1 , $matches);
#href="https://twitter.com/([^/]+)/status/([0-9]+)#
https://twitter.com/drupalplanet/status/248414059467251713
array (
0 => 'href="https://twitter.com/Dries/status/248397811220115456',
1 => 'Dries',
2 => '248397811220115456',
)