in reply to regex escaping forward slash in regex

‘Dumb’ search-and-replaces (and I mean that as a comment on the code, not on you!) always strike fear in my heart; if we can't even parse such a rigid language as XML with regexes (which we can't, right? Or at least no sane person would?), how can we expect correctly to parse the rich grammar of a programming language? I always think of clbuttic.

If this were my job, the first thing I'd do would be to look at some means of getting at the internal, not textual, representation of a PHP program. The first result for PHP + AST is php-ast; I'm not sure if it does what you want, but you might be able to fold, spindle, and mutilate it, or else just look further down in the results.

  • Comment on Re: regex escaping forward slash in regex

Replies are listed 'Best First'.
Re^2: regex escaping forward slash in regex
by ikegami (Patriarch) on Dec 10, 2009 at 02:57 UTC

    Dumb search-and-replaces always strike fear in my heart

    I do dumb search-and-replaces a hundred times a day, mostly with my editor's search and replace box. There's nothing wrong with it if the process is supervised.

    In the OP's case, he can use a visual diff tool — I love Beyond Compare — to compare the pre- and post-change versions of his files and fix the mistakes.

    And then he has to do a manual search to change the ones the tool didn't catch.