[PD-dev] zexy/[regex] : allow backslashes ?

Alexandre Quessy listes at sourcelibre.com
Fri Dec 21 09:07:13 CET 2007


Hi IOhannes and the list,
I am looking (and wrapping) zexy/[regex] and I was wondering if you
could add a way to be able to use backslashes. They are very useful in
regex, but pretty much forbidden in Pd. Though, I am not sure that
they are so useful with POSIX regex, which is what zexy/[regex]
uses.(#include <regex.h>) I suggest to use backticks as a backslash
replacement, since they are allowed in pd. That is what I have done a
little while ago in externals/aalex/pcre.c

An here is how I replace backticks by backslashes. (There are dozens
of better ways to do this, of course)
-------------------
char *mask = _str_replace('`', '\\', pattern);

/** clone of the PHP function */
char *_str_replace(const char search, const char replace, const char *subject) {
  int i, len;
  char *result = strdup(subject);
  len = strlen(result);
  for (i = 0; i <= len; i++) {
    if(result[i] == search) {
      result[i] = replace;
    }
  }
  return result;
}
----------




----------------------
Alexandre Quessy
http://alexandre.quessy.net
http://www.puredata.info/Members/aalex




More information about the Pd-dev mailing list