Hi list,
I'm stuck with a 'string' problem which might be easy but I don't see how to solve it...
I have to replace certain characters in a symbol with ',' (comma) or ' ' (space). Or I have to create independent symbols ',' or ' ', but [symbol ,] or [symbol ,( don't work (same with space).
Would be glad about any hints.
OTOH, maybe I could prevent getting into this problem at all (but don't know how): I'm reading lists into a [textfile]. These lists consist of pairs of characters and corresponding ASCII values, like: a 65 c 67 e 69 First I replaced spaces with '_' because I can't write a 65 32 e 69 (I think Pd would just ignore the extra spaces) Then I replaced ',' with another character because Pd obviously interpreted the comma as a line ending character (although I [read ... cr( ) So I have to reconvert these characters within Pd.
If I had a possibility to have the original characters directly my life would be much easier...
Thanks for any help Urs
On Sun, 22 Jan 2006 21:38:36 +0100 Urs Liska pd@ursliska.de wrote:
I have to replace certain characters in a symbol with ',' (comma) or ' ' (space). Or I have to create independent symbols ',' or ' ', but [symbol ,] or [symbol ,( don't work (same with space).
well, i think it's possible to do that with py/pyext in about 3 or 4 lines of python code ...
tim
Thanks for the tip, but it's not doable for me (at least not now) as I don't know to write python code... Urs
Tim Blechmann schrieb:
On Sun, 22 Jan 2006 21:38:36 +0100 Urs Liska pd@ursliska.de wrote:
I have to replace certain characters in a symbol with ',' (comma) or ' ' (space). Or I have to create independent symbols ',' or ' ', but [symbol ,] or [symbol ,( don't work (same with space).
well, i think it's possible to do that with py/pyext in about 3 or 4 lines of python code ...
tim
I read:
Thanks for the tip, but it's not doable for me (at least not now) as I don't know to write python code...
it's not that difficult,
import re
s = re.sub("c",",",s) # where "c" is the char to be s = re.sub("c"," ",s) # replaced and s ist the string
HTH
x
see also: http://www.python.org/doc/ http://docs.python.org/lib/module-re.html
At 23:01 22.01.2006, you wrote:
I read:
Thanks for the tip, but it's not doable for me (at least not now) as I don't know to write python code...
it's not that difficult,
import re
('that is even harder!').replace('harder', 'simpler')
http://docs.python.org/lib/string-methods.html
sven.
Hallo, sven hat gesagt: // sven wrote:
At 23:01 22.01.2006, you wrote:
I read:
Thanks for the tip, but it's not doable for me (at least not now) as I don't know to write python code...
it's not that difficult,
import re
('that is even harder!').replace('harder', 'simpler')
CK is still spoiled by Perl. ;)
Frank Barknecht _ ______footils.org_ __goto10.org__
Thanks for the tip, but it's not doable for me (at least not now) as I don't know to write python code...
well, writing python is as easy as switching on the light ;-)
but i was wrong ... it's 6 lines in total :-)
t
Urs Liska wrote:
If I had a possibility to have the original characters directly my life would be much easier...
unfortunately you cannot (yet...) however, using [makefilename %c] allows you to create a one-character symbol with any character (you have to provide the ascii-value). a simple (well...not simple, rather hackish) way to replace one substring by another is using zexy's [s2l] and [l2s] objects, where you can specify the "delimiter" (aka substrings). i guess there are other objects as well, but i know of none.
time to code [sed]...
mfg.a.sdr IOhannes
Hello IOhannes, thanks for the info.
IOhannes m zmölnig schrieb:
Urs Liska wrote:
If I had a possibility to have the original characters directly my life would be much easier...
unfortunately you cannot (yet...) however, using [makefilename %c] allows you to create a one-character symbol with any character (you have to provide the ascii-value).
Well, this works well with the space character, but not with the comma (presumably neither with other special characters). When providing 44 (ascii-value for the comma), a symbol GUI shows ', when I [print] it, it shows '\, and when I concatenate several characters with [l2s] it gives me even 6 backslashes before the comma.
So I would still need a way to transfer a 44 to a comma symbol...
Still thankful for any more ideas. Urs
On Sun, 22 Jan 2006, IOhannes m zmölnig wrote:
unfortunately you cannot (yet...) however, using [makefilename %c] allows you to create a one-character symbol with any character (you have to provide the ascii-value). a simple (well...not simple, rather hackish) way to replace one substring by another is using zexy's [s2l] and [l2s] objects, where you can specify the "delimiter" (aka substrings). i guess there are other objects as well, but i know of none. time to code [sed]...
There's [regsub] in GridFlow and else Alexandre Quessy has written a C/PCRE-based external a few weeks ago (i don't recall whether it's been released or not).
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada
Urs Liska a écrit :
I'm stuck with a 'string' problem which might be easy but I don't see how to solve it...
I have to replace certain characters in a symbol with ',' (comma) or ' ' (space).
Do you want to transform symbols into sequences and lists?
Or I have to create independent symbols ',' or ' ', but [symbol ,] or [symbol ,( don't work (same with space).
Would be glad about any hints.
You could use my ascii externals. I hope you work in linux because there's only one old binary: http://puredata.info/Members/odradek/ascii-0.1.1.tar.bz2/file_view (the source code is provided but it not adapted to the new flext) -- Marc
Hello Marc,
Marc Lavallée schrieb:
Urs Liska a écrit :
I'm stuck with a 'string' problem which might be easy but I don't see how to solve it...
I have to replace certain characters in a symbol with ',' (comma) or ' ' (space).
Do you want to transform symbols into sequences and lists?
not necessarily. I want to read in characters from the keyboard or from text files and then display them in GEM. Everything works fine except for the characters that seem inevitably to be escaped in Pd...
Or I have to create independent symbols ',' or ' ', but [symbol ,] or [symbol ,( don't work (same with space).
Would be glad about any hints.
You could use my ascii externals. I hope you work in linux
Sorry, no, I'm still on Windows because there's only one old binary:
http://puredata.info/Members/odradek/ascii-0.1.1.tar.bz2/file_view (the source code is provided but it not adapted to the new flext)
And unfortunately I'm not ready (yet) to deal with C++ source files (or any source files to be used to create externals) :-(
Thanks for the tip anyway Urs
-- Marc