|
Author |
Topic: Multi-character delimiter for splitStrings() (Read 1462 times) |
|
zai
|
Multi-character delimiter for splitStrings()
« on: Mar 11th, 2004, 7:14am » |
|
Is there an overloaded version of splitStrings that can handle a delimiter that has multiple characters? (ie. something that's similar to php's explode) Or would i need to write my own function? Thanks, z
|
|
|
|
amoeba
|
Re: Multi-character delimiter for splitStrings()
« Reply #1 on: Mar 11th, 2004, 12:27pm » |
|
hi zai, You can either use the StringTokenizer from Java (see documentation) or modify this split function to do what you want. Should be fairly simple.
|
marius watz // amoeba http://processing.unlekker.net/
|
|
|
fry
|
Re: Multi-character delimiter for splitStrings()
« Reply #2 on: Mar 11th, 2004, 5:43pm » |
|
fwiw, this will be in 69 when it's available. could someone point me to an online copy of the 'explode' reference? there's a lot of intersection between p5/php folks i think, so we'd like to be able to include some similar features (such as this).
|
|
|
|
zai
|
Re: Multi-character delimiter for splitStrings()
« Reply #4 on: Mar 11th, 2004, 11:57pm » |
|
Thanks. Just wondering any chance we can get to use regular expressions in Processing eventually?
|
|
|
|
fry
|
Re: Multi-character delimiter for splitStrings()
« Reply #5 on: Mar 12th, 2004, 12:56am » |
|
thanks toxi, i'll give that a look. regarding regexps.. there is a library called 'oro' that's quite simple/nice. we use a 1.x version of it, the last to be supported by java 1.1 as part of p5. the file is oro.jar in the 'lib' folder, and you can make use of it by dropping oro.jar into the 'code' folder of your project. more info on this older version here: http://www.savarese.org/oro/ it weighs in at 27k, so i doubt we'll add its functionality directly to p5, since that would increase the jar file size for everyone by 50%. since the earlier releases, oro has become part of the apache/jakarta project, though i think this code is all post-1.1: http://jakarta.apache.org/oro/index.html there is limited support for regexps in the split() function in java 1.4, so if your target audience is using 1.4 (not a large population, from what i can tell) you can use its regexp stuff. i recommend the early oro stuff tho, since it'll keep your java 1.1 users (almost everyone on windows) happy.
|
|
|
|
kevinP
|
[OT] diff between split and explode?
« Reply #6 on: Mar 14th, 2004, 12:56am » |
|
on Mar 11th, 2004, 5:50pm, toxi_ wrote: It looks to me like explode does not use a true regex engine and can only handle simple strings as a delimiter (but then is faster), whereas split can use any regex as a delimiter. (Or did I misread this)
|
« Last Edit: Mar 14th, 2004, 12:58am by kevinP » |
|
Kevin Pfeiffer
|
|
|
fry
|
Re: Multi-character delimiter for splitStrings()
« Reply #7 on: Apr 14th, 2004, 2:32am » |
|
just looked into this.. the list() syntax version (example 2) is really nice, and it's certainly one of the things i miss in p5/java from perl (what i tend to use for scripting). pretty difficult to implement though, since it would require a language change (i.e. how do you scope the vars that are created?), not just on the preproc level, but prolly in the compiler. so, it's up there with 'foreach' in terms of *want* but also in terms of difficulty.
|
|
|
|
|