| Author |
Message |
< Erlang ~ Using regular expressions correctly with the re module |
| Volume |
Posted: Sat Jan 17, 2009 1:51 pm |
|
|
|
Joined: 01 Jan 2009
Posts: 5
|
I was looking through this module on how to do Perl-style regular expressions.
http://www.erlang.org/doc/man/re.html
I started experimenting with how it works. After spending hours looking into getting a basic parse, I could only get those exceptions. I'm not sure why. Here's an example demonstrating what I have:
Code: 1> Foo = "Hello World! 122.42".
"Hello World! 122.42"
2> re:compile("[0-9].[0-9]").
=ERROR REPORT==== 17-Jan-2009::08:48:01 ===
Error in process <0.31.0> with exit value: {undef,[{re,compile,["[0-9].[0-9]"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
** exited: {undef,[{re,compile,["[0-9].[0-9]"]},
{erl_eval,do_apply,5},
{shell,exprs,6},
{shell,eval_loop,3}]} **
3> re:run(Foo, "[0-9].[0-9]").
=ERROR REPORT==== 17-Jan-2009::08:48:27 ===
Error in process <0.34.0> with exit value: {undef,[{re,run,["Hello World! 122.42","[0-9].[0-9]"]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}
** exited: {undef,[{re,run,["Hello World! 122.42","[0-9].[0-9]"]},
{erl_eval,do_apply,5},
{shell,exprs,6},
{shell,eval_loop,3}]} **
4>
I googled for a tutorial or example, but most of those were either articles praising the re module or referring me to the regexp module. I'd like to be able to use the re module, since it's guaranteed to be regular expressions based on Perl.
Insights on where I'm going wrong? |
|
|
| Back to top |
|
| rvirding |
Posted: Sat Jan 17, 2009 4:21 pm |
|
|
|
User
Joined: 30 Aug 2006
Posts: 452
Location: Stockholm, Sweden
|
First and foremost, which version of Erlang are you using? The new module re is only found on the latest version, R12B-5. I have tested your examples on R12B-5 on Windows and both work there.
Also from where have you taken your distribution?
Robert |
|
|
| Back to top |
|
| Volume |
Posted: Sun Jan 18, 2009 11:37 pm |
|
|
|
Joined: 01 Jan 2009
Posts: 5
|
Code: Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.5.5 (abort with ^G)
1>
Also, I have version R11-B5. At least that's the number that I got from synaptic. I run Ubuntu on this machine and installed it through synaptic. |
|
|
| Back to top |
|
| Mazen |
Posted: Mon Jan 19, 2009 7:59 am |
|
|
|
User
Joined: 20 Jul 2006
Posts: 164
Location: London
|
Volume wrote: Code: Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.5.5 (abort with ^G)
1>
Also, I have version R11-B5. At least that's the number that I got from synaptic. I run Ubuntu on this machine and installed it through synaptic.
V5.5.5 is R11-B5 AFAIK... R12-B5 should be V5.6.5.. |
|
|
| Back to top |
|
| rvirding |
Posted: Wed Jan 21, 2009 2:20 am |
|
|
|
User
Joined: 30 Aug 2006
Posts: 452
Location: Stockholm, Sweden
|
There are no problems in loading down the latest release and compiling it in Ubuntu though you will need to load some extra modules, though not many. ncurses and open-ssh are two I remember.
Robert |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|