substituting with a backslash in a regexp
could someone please enlighten me as to why the following does not replace all spaces with a backslash and a space ( ) ?
regexp @re " " @substitute "\ "
I'm trying to substitute all spaces in a file path with a backslash and a space so the path works with a "read" command in a pattrstorage to read the path to my preset xml file... otherwise the path truncates at a space in the path.
from reading the help file it says that two backslashes should give you a in your regex.
thanks for any help you might be able to offer...
On 22 avr. 08, at 05:44, ed guild wrote:
> could someone please enlighten me as to why the following does not
> replace all spaces with a backslash and a space ( ) ?
>
> regexp @re " " @substitute "\ "
>
> I'm trying to substitute all spaces in a file path with a backslash
> and a space so the path works with a "read" command in a
> pattrstorage to read the path to my preset xml file... otherwise the
> path truncates at a space in the path.
You shouldn't be using regexp for that. The real source of the problem
is that you have spaces in your path, so just deal with that. You may
have a look to [tosymbol] object, which allows you to make a symbol,
or maybe [sprintf] with the symout argument. Anyway, if you provide an
example of what you're doing, you'll get a more precise answer.
ej
ed guild schrieb:
> I'm trying to substitute all spaces in a file path with a backslash
> and a space so the path works with a "read" command in a pattrstorage
> to read the path to my preset xml file... otherwise the path
> truncates at a space in the path.
It wouldn't work anyway, and if you use a [tosymbol] with your "path
with spaces" any reading max object will happily take it as a complete
path and now what you want to load...
Stefan
--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com
thank you both for pointing me to the "tosymout" option. I wasn't aware of that.
this worked perfectly.
what I am doing is making a sub-patch that will take an input folder path (path to the main patch in my case) and then I'm using sprintf to add on a sub-folder and a file name.
this path to file name is used as the "read" and "write" file for a pattrstorage XML file.
I was having trouble reading from an included XML file when building my patch as a Mac OS X application.
So I figured if I kept my preset xml files in a "prefs" folder next to my patch/application, I could work around that issue.
here is the patch if you are interested in seeing my result.
thanks again for the help!
/ed