[erlang-questions] run strange behaviour
Alexander Petrovsky
askjuise@REDACTED
Wed Oct 23 21:26:52 CEST 2013
Hi!
I have the regex "^foo (\\w+(\\w* *)*) is an (\\w+(\\w* *)*)", and I get
strange behaviour when I do:
1> re:run(<<"foo bar is a foo bar is a big yellow boat or">>, <<"^foo
(\\w+(\\w* *)*) is a (\\w+(\\w* *)*)">>, [global, {capture, [1,3],
binary}]).
{match,[[<<"bar is a foo bar">>,<<"big yellow boat or">>]]}
2> re:run(<<"foo bar is a foo bar is a big yellow boat or sub">>, <<"^foo
(\\w+(\\w* *)*) is a (\\w+(\\w* *)*)">>, [global, {capture, [1,3],
binary}]).
nomatch
I tested this regexp in clojure and python:
=> (re-matches #"foo (\w+(\w* *)*) is a (\w+(\w* *)*)" "foo bar is a foo
bar is a big yellow boat or")
["foo bar is a foo bar is a big yellow boat or" "bar is a foo bar" "" "big
yellow boat or" ""]
=> (re-matches #"foo (\w+(\w* *)*) is a (\w+(\w* *)*)" "foo bar is a foo
bar is a big yellow boat or sub")
["foo bar is a foo bar is a big yellow boat or sub" "bar is a foo bar" ""
"big yellow boat or sub" ""]
>>> import re
>>> p = re.compile('foo (\w+(\w* *)*) is a (\w+(\w* *)*)')
>>> p.match("foo bar is a foo bar is a big yellow boat or")
<_sre.SRE_Match object at 0x100293c00>
>>> p.match("foo bar is a foo bar is a big yellow boat or sub")
<_sre.SRE_Match object at 0x100293ab0>
Can someone explain me, why I get on second string "foo bar is a foo bar is
a big yellow boat or sub" nomatch? This is a bug?
--
Петровский Александр / Alexander Petrovsky,
Skype: askjuise
Jabber: juise@REDACTED
Phone: +7 914 8 820 815 (irkutsk)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20131023/bdc8d418/attachment.htm>
More information about the erlang-questions
mailing list