Hi Slava & Co.,
Ruby and Perl do it this way:
>> "sdfh923oweop23dfosdhf0sdofo".split(/[0-9]*/)
=> ["s", "d", "f", "h", "o", "w", "e", "o", "p", "d", "f", "o", "s", "d", "h",
"f", "s", "d", "o", "f", "o"]
Python goes another way:
>>> re.split(r"[0-9]*", "sdfh923oweop23dfosdhf0sdofo")
['sdfh', 'oweop', 'dfosdhf', 'sdofo']
Ruby and Perl split a string into the single characters when you
just supply an empty string as pattern. Python ignores it.
>> "Ruby".split("")
=> ["R", "u", "b", "y"]
>>> re.split("", "Python")
['Python']
I guess this feature is useful in Perl, because now you can
easily iterate over the single characters of a string. This isn't
needed for Ruby and Python.
And Factor doesn't need to split strings into single characters,
too.
I'd say the Python way would be appropriate.
Slava Pestov <[EMAIL PROTECTED]> wrote:
> Hi Stefan,
>
> The problem is that [0-9]* matches an empty string. The fact that it
> hangs is a bug, but what should be the appropriate behavior in this
> case?
>
> Slava
>
> On Tue, Sep 30, 2008 at 4:08 AM, Stefan Scholl <[EMAIL PROTECTED]> wrote:
>> Just testing re-split (vocab "regexp):
>>
>> USE: regexp
>> "sdfh923oweop23dfosdhf0sdofo" "[0-9]*" <regexp> re-split
>>
>>
>> And now Factor hangs. Process at full 50 % (dual cores are funny).
>>
>>
>> Factor build 492, Windows XP.
>>
>>
>> --
>> Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/
>>
>>
>> -------------------------------------------------------------------------
>> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
>> Build the coolest Linux based applications with Moblin SDK & win great prizes
>> Grand prize is a trip for two to an Open Source event anywhere in the world
>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Factor-talk mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
--
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk