Re: regex: force entire string to match

2012-01-31 Thread bearophile
NewName: > Hello all. > I want to write a regex to check if a whole string is a number. Also: import std.stdio, std.string, std.array; void main() { string s = "123"; assert(s.removechars("0-9").empty); } Bye, bearophile

Re: regex: force entire string to match

2012-01-31 Thread NewName
> You want to match the beginning and end of the input as well: > "^[0-9]+$" Thanks.

Re: regex: force entire string to match

2012-01-31 Thread Justin Whear
On Tue, 31 Jan 2012 16:29:43 +, NewName wrote: > Hello all. > I want to write a regex to check if a whole string is a number. With my > current regex("[0-9]+") numbers will be carved out of things like > "aaa456" (hit: 456) and I circumvent this by checking the lengths for > inequality, which

Re: regex: force entire string to match

2012-01-31 Thread Trass3r
I want to write a regex to check if a whole string is a number. With my current regex("[0-9]+") numbers will be carved out of things like "aaa456" (hit: 456) and I circumvent this by checking the lengths for inequality, which is stupid. My regex is surely missing something? Try ^ and $ if applic

regex: force entire string to match

2012-01-31 Thread NewName
Hello all. I want to write a regex to check if a whole string is a number. With my current regex("[0-9]+") numbers will be carved out of things like "aaa456" (hit: 456) and I circumvent this by checking the lengths for inequality, which is stupid. My regex is surely missing something? Thank you fo