Seenthis
•
 
Identifiants personnels
  • [mot de passe oublié ?]

 
  • #r
  • #re
  • #regex
RSS: #regexp

#regexp

  • #regexplibrary
  • Fil @fil 10/12/2012 13:45
    1
    @speciale
    1

    Passage à PHP 5.3 et disparition des ereg

    Deprecated: Function eregi_replace() is deprecated

    Si votre serveur passe de PHP 5.2 à PHP 5.3, vous aurez peut-être la surprise de voir cet avertissement s’afficher partout ; c’est pas beau ! En fait les fonctions de la famille ereg_* (#ereg, eregi, ereg_replace et eregi_replace) continuent à fonctionner à l’identique, mais provoquent cette annonce, car les “Dieux de #PHP” (si une telle chose existe) ont décidé d’en finir avec elles. Pour s’en sortir :

    1. Modifier les appels de fonction
    – ereg(’x’…) devient preg_match(’/x/’…)
    – eregi(’x’…) devient preg_match(’/x/i’…)
    – ereg_replace(’x’…) devient preg_replace(’/x/’…)
    – eregi_replace(’x’…) devient preg_replace(’/x/i’…)

    ça peut être long à faire surtout si c’est des centaines de vieux fichiers dont on ne sait plus à quoi ça sert…

    2. Masquer les avertissements
    depuis quelques versions, par défaut #SPIP fait ceci :
    – error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED)
    il est bien évidemment possible de faire pareil dans d’autres scripts
    ou alors, sur chaque ligne concernée, ajouter un @
    – @ereg(…)

    3. Quand ereg() aura disparu
    On peut espérer, quand ereg() aura disparu (pour PHP 7 ?) qu’il sera possible de définir soi-même les fonctions ereg() avec un
    if(!function_exists(’ereg’)) { function ereg() { ………} }
    je n’ai pas trouvé de telle "librairie", mais ce ne sera pas forcément trop difficile à produire et à installer dans le script d’auto_prepend (là où je mets l’#écran_de_sécurité).

    #regexp

    • #PHP
    Fil @fil
    Écrire un commentaire

  • liotier @liotier CC BY-SA 13/11/2012 14:00
    3
    @fil
    @gblin
    @touti
    3

    You can’t parse [X]HTML with regex. Just don’t. Bad things will happen. You don’t want to know : http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 - Stackoverflow now features a computational demonology section, brought to you by Capital Laundry Services...

    • #HTML
    • #HTML
    • #XML
    • #programmer
    • #visual basic
    • #ML
    liotier @liotier CC BY-SA
    • Fil @fil 13/11/2012 14:05

      reg​ex parsers for HTML will ins​tantly transport a programmer’s consciousness into a world of ceaseless screaming, he comes, the pestilent slithy regex-infection wil​l devour your HT​ML parser, application and existence for all time like Visual Basic only worse he comes he comes do not fi​ght he com̡e̶s, ̕h̵i​s un̨ho͞ly radiańcé destro҉ying all enli̍̈́̂̈́ghtenment, HTML tags lea͠ki̧n͘g fr̶ǫm ̡yo​͟ur eye͢s̸ ̛l̕ik͏e liq​uid pain, the song of re̸gular exp​ression parsing will exti​nguish the voices of mor​tal man from the sp​here I can see it can you see ̲͚̖͔̙î̩́t̲͎̩̱͔́̋̀ it is beautiful t​he final snuffing of the lie​s of Man ALL IS LOŚ͖̩͇̗̪̏̈́T ALL I​S LOST the pon̷y he comes he c̶̮omes he comes the ich​or permeates all MY FACE MY FACE ᵒh god no NO NOO̼O​O NΘ stop the an​*̶͑̾̾​̅ͫ͏̙̤g͇̫͛͆̾ͫ̑͆l͖͉̗̩̳̟̍ͫͥͨe̠̅s ͎a̧͈͖r̽̾̈́͒͑e n​ot rè̑ͧ̌aͨl̘̝̙̃ͤ͂̾̆ ZA̡͊͠͝LGΌ ISͮ̂҉̯͈͕̹̘̱ TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡ H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ

      Fil @fil
    • Fil @fil 13/11/2012 14:07

      #poésie #informatique #regexp #programmation

      Fil @fil
    • klaus++ @klaus 13/11/2012 18:00
      @fil

      #seenthis vient de bouffer mon commentaire (fenêtre ouverte depuis trois heures, @fil était plus rapide que moi pour faire le premier commentaire, alors conflit de #ID_FORUM)

      klaus++ @klaus
    • klaus++ @klaus 13/11/2012 18:04

      LOL pourtant :

      This is the regex I use (!) to match HTML tags:

      <(?:"[^"]"[’"]|’[^’]’[’"]|[^’">])+>

      It may not be perfect, but I ran this code through a lot of HTML. Note that it even catches strange things like <a name="badgenerator"">, which show up on the web.

      I guess to make it not match self contained tags, you’d either want to use Kobi’s negative look-behind:

      <(?:"[^"]"[’"]|’[^’]’[’"]|[^’">])+(?<!/\s*)>

      or just combine if and if not.

      To downvoters: This is working code from an actual product. I doubt anyone reading this page will get the impression that it is socially acceptable to use regexes on HTML.

      Caveat: I should note that this regex still breaks down in the presence of CDATA blocks, comments, and script and style elements. Good news is, you can get rid of those using a regex...

      klaus++ @klaus
    Écrire un commentaire

  • (⊙.⊙)☂ @fil 8/11/2012 10:57

    BanzaiMan/regexp_library
    https://github.com/BanzaiMan/regexp_library

    #RegexpLibrary is a collection of regular expressions for general use.

    analyse d’IP, d’URLs, d’adresses email etc. Pourquoi réinventer le truc (mal) à chaque fois. #programmation #python

    • #BanzaiMan/regexp library
    (⊙.⊙)☂ @fil
    Écrire un commentaire

  • Suske @suske CC BY 27/08/2012 13:43
    1
    @solidairnet
    1

    Tutoriel sur l’URL Rewriting (réécriture d’URL)
    http://www.webrankinfo.com/dossiers/techniques/tutoriel-url-rewriting#reecriture

    Le format de l’URL à réécrire est basé sur les expressions régulières, dont la base devra être acquise pour pouvoir définir des règles de réécriture. Ne vous inquiétez pas, pour la plupart des cas c’est très simple.

    Voici la liste des éléments pris en considération dans les règles de réécriture :

    #url_rewriting #regexp #url

    • #URL
    • #Google
    Suske @suske CC BY
    Écrire un commentaire

  • Stéphane Bortzmeyer @stephane CC BY-SA 23/08/2011 15:04
    1
    @aris
    1

    Les #regexp sont-elles mauvaises pour la santé ou, en tout cas, pour les performances ?

    http://commandcenter.blogspot.com/2011/08/regular-expressions-in-lexing-and.html

    I should say something about regular expressions in lexing and parsing. Regular expressions are hard to write, hard to write well, and can be expensive relative to other technologies. [...]

    #analyse-lexicale #analyse-syntaxique

    • #search tools
    Stéphane Bortzmeyer @stephane CC BY-SA
    Écrire un commentaire

  • 0gust1 @0gust1 CC BY-NC 15/03/2010 12:14

    15 PHP regular expressions for web developers
    http://www.catswhocode.com/blog/15-php-regular-expressions-for-web-developers

    #regexp #regex #regular #php #web #webdev

    • #PHP
    • #PHP
    • #regex regular php web webdev
    • #PHP
    • #web developers
    • #search results
    • #HTML
    0gust1 @0gust1 CC BY-NC
    Écrire un commentaire

  • Nicolas Hoizey @nhoizey CC BY-NC-SA 19/01/2010 05:10

    Free RegEx Testing Tool for MacOSX, Windows, and Linux
    http://www.gskinner.com/RegExr/desktop

    “RegExr Desktop is a tool for learning, editing, and testing regular expressions (RegEx or RegExp for short) on Mac OSX, Windows, and Linux.”

    #RegExp #expression_régulière #expression_rationnelle #regex #test #dev #mac #logiciel #AIR #clevermarks

    Nicolas Hoizey @nhoizey CC BY-NC-SA
    Écrire un commentaire

  • 0gust1 @0gust1 CC BY-NC 2/12/2009 11:15

    RegExr : Online Regular Expression Testing Tool
    http://gskinner.com/RegExr

    #regular #expression #regex #utilities #webdev #reference #programming #tools #code #regexp

    • #regular expression regex utilities webdev reference programming
    0gust1 @0gust1 CC BY-NC
    Écrire un commentaire

  • 0gust1 @0gust1 CC BY-NC 24/08/2009 07:37

    JavaScript RegExp Object Reference
    http://www.w3schools.com/jsref/jsref_obj_regexp.asp

    #javascript #regexp #reference #programming #web #webdev

    0gust1 @0gust1 CC BY-NC
    Écrire un commentaire

  • Seenthis @seenthis CC BY-NC 30/07/2009 19:05

    Je viens de passer le test de la présence (ou non) du lien « Supprimer » au survol des messages entièrement en #javascript. De cette façon il n’y a plus aucun élément dynamique dans l’affichage d’un message, et j’ai donc passé l’appel d’un message en #microcache.

    Le principe est grosso modo le même que dans l’affichage de l’âge d’un message : je stocke les infos dont j’ai besoin (id_auteur du message, id_auteur du parent) dans le #rel du lien hypertexte, puis c’est javascript qui se débrouille au survol de chaque message pour savoir s’il doit afficher le lien « Supprimer ».

    Astuce : pour simplifier le javascript, le #regexp est directement encodé dans le #rel. Du genre ^(1|2)$. Je récupère donc la valeur du #rel, et je l’applique directement en regexp à l’identifiant de l’auteur connecté.

    Seenthis @seenthis CC BY-NC
    • Seenthis @seenthis CC BY-NC 30/07/2009 19:07

      Prochaine étape : passer l’ensemble du fil de messages en #microcache.

      Seenthis @seenthis CC BY-NC
    Écrire un commentaire

  • 0gust1 @0gust1 CC BY-NC 9/02/2009 12:48

    JavaScript Lab - Tools - JS Regex Generator
    http://www.jslab.dk/tools.regex.php

    #javascript #webdev #tools #regexp

    • #javascript webdev tools
    • #JavaScript Lab
    • #JavaScript
    0gust1 @0gust1 CC BY-NC
    Écrire un commentaire

  • 0gust1 @0gust1 CC BY-NC 29/07/2008 23:56

    Regular Expression Tutorial - Learn How to Use Regular Expressions
    http://www.regular-expressions.info/tutorial.html

    #regexp #web #dev #howto

    • #regexp web dev howto
    • #Perl
    0gust1 @0gust1 CC BY-NC
    Écrire un commentaire

Thèmes liés

  • #dev
  • #javascript
  • #microcache
  • #php
  • Currency: PHP
  • #programmation
  • #programming
  • #reference
  • #regex
  • #regular
  • #tools
  • #web
  • #webdev