digitalmars.D - Problem with RegExp
- Matthew (15/15) Jan 02 2008 I was playing around with RegExp and noticed it is not working like I th...
- Russell Lewis (2/26) Jan 02 2008 Do you need a double-backslash?
- Matthew (2/29) Jan 02 2008 I did until I put the r before the quote. r"". Still got same behavior t...
- dennis luehring (3/16) Jan 02 2008 i think its a bug
- Matthew (14/33) Jan 02 2008 I didn't want to say it was a bug cause whenever I do that I get jinxed ...
- dennis luehring (3/3) Jan 02 2008 maybe we can use the regex test suit from the perl-source
- Matthew (3/8) Jan 02 2008 I don't have perl or sources on my comp. It's Windows and I just got it....
- Tom (4/6) Jan 02 2008 RegExp has been broken for quite some time now. Search Bugzilla and you'...
- Matthew (2/10) Jan 02 2008 So I've noticed since posting.
- Dan (3/4) Jan 02 2008 Sincerely, truly, wholeheartedly...
- Matthew (2/9) Jan 02 2008 It's the VM . Not that I have a problem with VM's but if I want to write...
I was playing around with RegExp and noticed it is not working like I think it should be working. This is the same with both 1.0 and 2.0. import std.stdio; import std.regexp; void main (char [][] args) { string text = "Why doesn't it find the sssss's?"; RegExp pattern = new RegExp(r"[^\s]+"); //Notice the escape code in the expression. RegExp list = pattern.search(text); foreach(m; list) { writefln(m.match(0)); } } The regular expression should match one or more non-whitespace characters. On my comp the whitespace characters don't match, but neither do lower case s's. Interestingly enough if I try the following. RegExp pattern = new RegExp(r"[^\W]+"); I get the exact same behavior except now capitol W's aren't matched instead of lower case s's. I don't know if this is a bug or not as I've never used RegExp class before, but I wonder if it does this for everyone?
Jan 02 2008
Matthew wrote:I was playing around with RegExp and noticed it is not working like I think it should be working. This is the same with both 1.0 and 2.0. import std.stdio; import std.regexp; void main (char [][] args) { string text = "Why doesn't it find the sssss's?"; RegExp pattern = new RegExp(r"[^\s]+"); //Notice the escape code in the expression. RegExp list = pattern.search(text); foreach(m; list) { writefln(m.match(0)); } } The regular expression should match one or more non-whitespace characters. On my comp the whitespace characters don't match, but neither do lower case s's. Interestingly enough if I try the following. RegExp pattern = new RegExp(r"[^\W]+"); I get the exact same behavior except now capitol W's aren't matched instead of lower case s's. I don't know if this is a bug or not as I've never used RegExp class before, but I wonder if it does this for everyone?Do you need a double-backslash?
Jan 02 2008
Russell Lewis Wrote:Matthew wrote:I did until I put the r before the quote. r"". Still got same behavior though.I was playing around with RegExp and noticed it is not working like I think it should be working. This is the same with both 1.0 and 2.0. import std.stdio; import std.regexp; void main (char [][] args) { string text = "Why doesn't it find the sssss's?"; RegExp pattern = new RegExp(r"[^\s]+"); //Notice the escape code in the expression. RegExp list = pattern.search(text); foreach(m; list) { writefln(m.match(0)); } } The regular expression should match one or more non-whitespace characters. On my comp the whitespace characters don't match, but neither do lower case s's. Interestingly enough if I try the following. RegExp pattern = new RegExp(r"[^\W]+"); I get the exact same behavior except now capitol W's aren't matched instead of lower case s's. I don't know if this is a bug or not as I've never used RegExp class before, but I wonder if it does this for everyone?Do you need a double-backslash?
Jan 02 2008
void main (char [][] args) { string text = "Why doesn't it find the sssss's?"; RegExp pattern = new RegExp(r"[^\s]+"); //Notice the escape code in the expression. RegExp list = pattern.search(text); foreach(m; list) { writefln(m.match(0)); } }i think its a bug \s machtes invisible chars AND the char s [^\s] seem to be interpreted like [^s\s]
Jan 02 2008
dennis luehring Wrote:I didn't want to say it was a bug cause whenever I do that I get jinxed and it demonstrate the problem. using System; using System.Text.RegularExpressions; class MyClass { public static void Main (String [] args) { string text = "Does it find the ssssss's?"; Regex pattern = new Regex( "[^\s]+"); foreach (Match m in pattern.Matches(text)) { Console.WriteLine(m); } } } Now I'm going to continue writing my new D program because if I have to write public static void Main one more time I think I'm just gonna snap.void main (char [][] args) { string text = "Why doesn't it find the sssss's?"; RegExp pattern = new RegExp(r"[^\s]+"); //Notice the escape code in the expression. RegExp list = pattern.search(text); foreach(m; list) { writefln(m.match(0)); } }i think its a bug \s machtes invisible chars AND the char s [^\s] seem to be interpreted like [^s\s]
Jan 02 2008
maybe we can use the regex test suit from the perl-source \t\op\regexp.t - testprogram \t\op\re_tests - testcases
Jan 02 2008
dennis luehring Wrote:maybe we can use the regex test suit from the perl-source \t\op\regexp.t - testprogram \t\op\re_tests - testcasesI don't have perl or sources on my comp. It's Windows and I just got it. So, it really doesn't have anything on it. But apparently from the bug reports RegExp is pretty buggy. Apparently both phobos and tango regex's are pretty buggy. So it would probably fail in many places. If I was ambitious I might try and write another regex lib, however I'm sure someone else is already working on this. Perhaps if it was really that important a well tested C or C++ regex library could just be wrapped by D. That would save a lot of time.
Jan 02 2008
Matthew escribió:I was playing around with RegExp and noticed it is not working like I think it should be working. This is the same with both 1.0 and 2.0. ...RegExp has been broken for quite some time now. Search Bugzilla and you'll see. -- Tom;
Jan 02 2008
Tom Wrote:Matthew escribió:So I've noticed since posting.I was playing around with RegExp and noticed it is not working like I think it should be working. This is the same with both 1.0 and 2.0.> ... RegExp has been broken for quite some time now. Search Bugzilla and you'll see. -- Tom;
Jan 02 2008
Matthew Wrote:Now I'm going to continue writing my new D program because if I have to write public static void Main one more time I think I'm just gonna snap.Sincerely, truly, wholeheartedly... reasons, but I have D and IDA Pro now.
Jan 02 2008
Dan Wrote:Matthew Wrote:It's the VM . Not that I have a problem with VM's but if I want to write in language as languages go. It's the implementation that gets me.Now I'm going to continue writing my new D program because if I have to write public static void Main one more time I think I'm just gonna snap.Sincerely, truly, wholeheartedly... reasons, but I have D and IDA Pro now.
Jan 02 2008