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

Robert Virding robert.virding@REDACTED
Tue Apr 19 23:14:04 CEST 2011


Perhaps its because they think that adding/subtracting one is too difficult. Or perhaps it is because they want to adhere to the convention that indexing starts at 0 in spite of that most other erlang things index from 1. 

Robert 

----- "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 
> 
> 

> -- 
> Best Regards, 
> - Ahmed Omar 
http://nl.linkedin.com/in/adiaa 
Follow me on twitter 
@spawn_think 
> 
> _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110419/f838939f/attachment.htm>


More information about the erlang-questions mailing list