Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 02, 2005 Regular expressions | ||||
---|---|---|---|---|
| ||||
Hi again, this time i got a problem with regexp. The documentation says: int search(char[] string) Search string[] for match with regular expression. Returns Description >=0 index of match -1 no match But this program: <code> private import std.regexp; private import std.stdio; int main(char[][] arg) { char[] str1 = "TEST"; char[] str2 = "TEST.bmp"; RegExp regexp = new RegExp("\\.bmp$", "i"); int i = regexp.search(str1); int j = regexp.search(str2); writef("regexp.search(\"%s\") == %s\n", str1, i); writef("regexp.search(\"%s\") == %s\n", str2, j); return 0; } </code> prints: regexp.search("TEST") == 0 regexp.search("TEST.bmp") == 1 ... what am i doing wrong? Thanks, Markus |
January 02, 2005 Re: Regular expressions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Markus Dangl | Markus Dangl wrote:
> (...)
>
> prints:
>
> regexp.search("TEST") == 0
> regexp.search("TEST.bmp") == 1
>
> ... what am i doing wrong?
I don't know. That's weird, here's my output:
regexp.search("TEST") == -1
regexp.search("TEST.bmp") == 4
DMD.110; WinXP.SP2.En
|
January 03, 2005 Re: Regular expressions | ||||
---|---|---|---|---|
| ||||
Posted in reply to h3r3tic | h3r3tic schrieb:
> Markus Dangl wrote:
>
>> (...)
>>
>> prints:
>>
>> regexp.search("TEST") == 0
>> regexp.search("TEST.bmp") == 1
>>
>> ... what am i doing wrong?
>
>
> I don't know. That's weird, here's my output:
>
> regexp.search("TEST") == -1
> regexp.search("TEST.bmp") == 4
>
> DMD.110; WinXP.SP2.En
oh i forgot: DMD.110; WinXP.SP2.De
This "bug" occurs since i upgraded from DMD.109
|
January 03, 2005 Re: Regular expressions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Markus Dangl | "Markus Dangl" <danglm@in.tum.de> wrote in message news:craef3$um0$1@digitaldaemon.com... > h3r3tic schrieb: > > Markus Dangl wrote: > > > >> (...) > >> > >> prints: > >> > >> regexp.search("TEST") == 0 > >> regexp.search("TEST.bmp") == 1 > >> > >> ... what am i doing wrong? > > > > > > I don't know. That's weird, here's my output: > > > > regexp.search("TEST") == -1 > > regexp.search("TEST.bmp") == 4 > > > > DMD.110; WinXP.SP2.En > > oh i forgot: DMD.110; WinXP.SP2.De > > This "bug" occurs since i upgraded from DMD.109 I also get the correct results (-1 and 4) with 110. |
Copyright © 1999-2021 by the D Language Foundation