[erlang-questions] beginner: How should regexp:split/2 be replaced?

Ahmed Omar spawn.think@REDACTED
Tue Apr 19 16:26:57 CEST 2011


Well the documentation already state it so i believe no need to reply that
side question :)
The default return type is (zero-based) indexes of the captured parts of the
string, given as {Offset,Length} pairs (the index Type of capturing).


On Tue, Apr 19, 2011 at 4:21 PM, Ahmed Omar <spawn.think@REDACTED> wrote:

> I mean i understand it's different indexing, but was there specific reason
> to change that?
>
>
> On Tue, Apr 19, 2011 at 4:18 PM, Ahmed Omar <spawn.think@REDACTED> wrote:
>
>> regexp:split("Hello world, Hello", "[ ]*,[ ]*").
>> {ok,["Hello world","Hello"]}
>>
>> re:split("Hello world, Hello", "[ ]*,[ ]*",[{return, list}]).
>> ["Hello world","Hello"]
>>
>> regexp:matches("Hello \n","\n").
>> {match,[{7,1}]}
>>
>> re:run("Hello \n","\n").
>> {match,[{6,1}]}
>>
>> but i'm not sure why the start position is different here
>>
>> On Tue, Apr 19, 2011 at 3:30 PM, Bengt Kleberg <
>> bengt.kleberg@REDACTED> wrote:
>>
>>> Greetings,
>>>
>>> I have inherited some code without a test directory. I get the following
>>> compiler warnings:
>>> ./compile_funcs.erl:603: Warning: regexp:split/2: the regexp module is
>>> deprecated (will be removed in R15A); use the re module instead
>>> ./compile_funcs.erl:645: Warning: regexp:matches/2: the regexp module is
>>> deprecated (will be removed in R15A); use the re module instead
>>>
>>> The lines are:
>>>            {ok, Class} = regexp:split(Class0, "[ ]*,[ ]*"),
>>> and
>>>    {match,A}=regexp:matches(String,"\n"),
>>>
>>> I thought "[ ]*,[ ]*" would mean:
>>> the character class of " " (space), 0 or many times, followed by literal
>>> "," followed by the character class of " " (space), 0 or many times.
>>>
>>> This is not the case and I am not having any luck with randomly
>>> constructing strings to find one that triggers a Class that is different
>>> from Class0.
>>>
>>> Perhaps someone knows what "[ ]*,[ ]*" really means, and what to replace
>>> these with when using the re module.
>>>
>>>
>>> bengt
>>>
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>
>>
>>
>>
>> --
>> Best Regards,
>> - Ahmed Omar
>> http://nl.linkedin.com/in/adiaa
>> Follow me on twitter
>> @spawn_think <http://twitter.com/#!/spawn_think>
>>
>>
>
>
> --
> Best Regards,
> - Ahmed Omar
> http://nl.linkedin.com/in/adiaa
> Follow me on twitter
> @spawn_think <http://twitter.com/#!/spawn_think>
>
>


-- 
Best Regards,
- Ahmed Omar
http://nl.linkedin.com/in/adiaa
Follow me on twitter
@spawn_think <http://twitter.com/#!/spawn_think>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110419/56988b9a/attachment.htm>


More information about the erlang-questions mailing list