메아리 저널

ere2pcre​

Yesterday someone asked me for a reasonable way to convert ereg* functions (which he had a lot) to pcre_* functions; while ereg* functions are a part of PHP for a long time, they are finally deprecated as of PHP 5.3.0 and it is time to move on. Unfortunately a quick search didn’t found some converter, so I made my own: ere2pcre.

ere2pcre is a drop-in replacement for ereg* functions. My sample implementation contains myereg* functions that can readily replace ereg* functions (to the extent that it emulates the exact interface of ereg* functions). Alternatively you can simply use ere2pcre function to convert the ERE to the PCRE and do the remaining job yourself. Which way is better depends on your situation. It doesn’t support a collation class ([.ch.]) and equivalence class ([=ch=]) as PCRE doesn’t support them either, but who cares? ;)

The source code can be downloaded from Gist. The full source code follows:


노트들

  1. arachneng posted this
텀블러를 씁니다.