[erlang-questions] Regular Expressions in Erlang

Tomasz Blachowicz <>
Wed Dec 19 19:14:17 CET 2007


Hi,

I've a couple of questions about regular expressions in Erlang:
* Is it possible to capture groups? When I use a pattern "foo(bar)" against
string "foobar" I expect to be able to access substring "bar" captured in
grouping brackets.
* Why "curly bracket" quantifiers can't be used? I mean, usually pattern
"fo{2}bar" matches "foobar", but not in Erlang, because regexp module
doesn't handle this syntax. Am I right?
* Is it possible to specify some parts of a pattern no to be greedy? Most
quantifiers are greedy e.g. *, so it there any way to turn off the
greediness in some cases?

If there are any other decent implementations of regexp available please let
me know.

Basically, my requirement is to match some strings and extract bits from
these. Let's say I have string:

<img src=\"/icons/folder.gif\" alt=\"[DIR]\"> <a
href=\"c3p0-oracle-thin-extras/\">c3p0-oracle-thin-extras/</a> 04-Jan-2007
13:19    -
<img src="/icons/text.gif" alt="[TXT]"> <a href="maven-metadata.xml.sha1">
maven-metadata.xml.sha1</a> 09-Jul-2006 08:39  132

and I want to extract "DIR" or "TXT", href value and possible a date and
size at the end of each string.

In other languages I used to do it using regexp, but now I have to implement
my logic in Erlang and I don't know exactly how to accomplish this task.

Any help would be highly appreciated,

Kind Regards,
Tomasz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20071219/be8031e8/attachment.html>


More information about the erlang-questions mailing list