Problem with RegExp
Matthew
matthewcsims at gmail.com
Wed Jan 2 12:29:30 PST 2008
dennis luehring Wrote:
> > 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]
I didn't want to say it was a bug cause whenever I do that I get jinxed and it ends up being my own code, but equivalent code in C# doesn't seem to 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.
More information about the Digitalmars-d
mailing list