digitalmars.D.bugs - [Issue 1249] New: regular expression pattern [.] not matches any character
- d-bugmail puremagic.com (25/25) May 26 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1249
- d-bugmail puremagic.com (10/10) May 26 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1249
- d-bugmail puremagic.com (9/12) May 27 2007 since . not match newline, I try [.\s] to match anything, but failed. th...
- d-bugmail puremagic.com (6/9) Jun 21 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1249
- d-bugmail puremagic.com (9/9) Jun 28 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1249
http://d.puremagic.com/issues/show_bug.cgi?id=1249 Summary: regular expression pattern [.] not matches any character Product: D Version: 1.014 Platform: PC OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: bugzilla digitalmars.com ReportedBy: yidabu gmail.com regular expression pattern [.] not matches any character The following code shows it: import std.regexp; import std.stdio; void main() { char[] s = "a b"; char[] p = "[.]+"; s = std.regexp.sub(s, p, ""); writefln("s=%s,",s); // s not changed } --
May 26 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1249 ------- Comment #1 from wbaxter gmail.com 2007-05-26 23:52 ------- I think '.' and other special characters lose their special meaning inside a character class. So [.()$^] should match either a period, a paren, a dollar-sign, or a caret, and nothing else. If it's not documented as such then maybe this is a documentation needs to make that clear. That sort of behavior is pretty common of regexp implementations. Why would you want to put a 'match any character' symbol inside a 'match any of these characters' construct. [.] would mean the same thing as a plain period. --
May 26 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1249 ------- Comment #2 from yidabu gmail.com 2007-05-27 06:23 -------Why would you want to put a 'match any character' symbol inside a 'match any of these characters' construct. [.] would mean the same thing as a plain period.since . not match newline, I try [.\s] to match anything, but failed. the only way is (.|\s) PCRE: Note that special characters do not retain their special meanings inside [], with the exception of \\, \^, \-,\[ and \] match the escaped character inside a set. --
May 27 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1249 ------- Comment #3 from baryluk mpi.int.pl 2007-06-21 11:19 ------- (In reply to comment #1)I think '.' and other special characters lose their special meaning inside a character class. So [.()$^] should match either a period, a paren, a dollar-sign, or a caret, and nothing else.You are rigth, but actually ^ must be escaped: [.()$\^]. And IMHO this is not a bug. One can discuss but most of regular expression eninges also does so. --
Jun 21 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1249 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #4 from bugzilla digitalmars.com 2007-06-28 22:12 ------- Works as designed. --
Jun 28 2007