digitalmars.D.learn - Regexp help (possible bug?)
- gareis <dhasenan gmail.com> May 26 2007
- gareis <dhasenan gmail.com> May 26 2007
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> May 26 2007
- Deewiant <deewiant.doesnotlike.spam gmail.com> May 26 2007
- Don Clugston <dac nospam.com.au> May 29 2007
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> May 29 2007
- Chris Nicholson-Sauls <ibisbasenji gmail.com> May 29 2007
- davidb <ta-nospam-zz gmx.at> May 26 2007
---
import std.regexp;
int main () {
char[] foo = "foo = bar";
int i = std.regexp.find(foo, "[^\\]#");
return 0;
}
---
This outputs "Error: invalid range". According to the documentation, this
should return -1, since the input does not contain an octalthorpe (#) that is
not preceded by a backslash.
Adding an octalthorpe doesn't help matters; it produces the same error. Also,
adding the attribute argument doesn't help.
With an example this small, I think this is probably a bug, but I'd like to
check here before submitting a report -- am I doing something wrong?
May 26 2007
Argh -- forget that. I forget that regexps require an extra level of escaping; that should have been: --- std.regexp.find(foo, "[^\\\\]#"); --- This is why I ask now rather than submitting bug reports first. Thanks!
May 26 2007
"gareis" <dhasenan gmail.com> wrote in message news:f399o6$n1f$1 digitalmars.com...Argh -- forget that. I forget that regexps require an extra level of escaping; that should have been: --- std.regexp.find(foo, "[^\\\\]#");
If you use WYSIWYG strings, you can avoig the ugly double escaping: std.regexp.find(foo, r"[^\\]#"); or std.regexp.find(foo, `[^\\]#`); I've also never heard of a pound sign being called an "octalthorpe"?
May 26 2007
Jarrett Billingsley wrote:I've also never heard of a pound sign being called an "octalthorpe"?
http://en.wikipedia.org/wiki/Number_sign -- Remove ".doesnotlike.spam" from the mail address.
May 26 2007
Deewiant wrote:Jarrett Billingsley wrote:I've also never heard of a pound sign being called an "octalthorpe"?
http://en.wikipedia.org/wiki/Number_sign
(BTW, what do you call ₤?)
May 29 2007
"Don Clugston" <dac nospam.com.au> wrote in message news:f3grec$uqq$1 digitalmars.com...
what do you call ??)
Oh I guess that's called a pound sign too, but whenever you say "pound sign" here it means almost certainly #. We might call ? a "British pound sign" or so.
May 29 2007
Jarrett Billingsley wrote:"Don Clugston" <dac nospam.com.au> wrote in message news:f3grec$uqq$1 digitalmars.com...Where I come from, 'pound sign' has always meant ?, and # is 'hash'. (BTW, what do you call ??)
Oh I guess that's called a pound sign too, but whenever you say "pound sign" here it means almost certainly #. We might call ? a "British pound sign" or so.
I've oft heard it called a "Sterling". -- Chris Nicholson-Sauls
May 29 2007
gareis schrieb:Argh -- forget that. I forget that regexps require an extra level of escaping; that should have been: --- std.regexp.find(foo, "[^\\\\]#"); --- This is why I ask now rather than submitting bug reports first. Thanks!
--- int i = std.regexp.find(foo, r"[^\\]#"); --- works as well david
May 26 2007









Chris Nicholson-Sauls <ibisbasenji gmail.com> 