Hack Forums
[Help] Regex int from 01 to 99? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: [Help] Regex int from 01 to 99? (/showthread.php?tid=5042707)



Regex int from 01 to 99? - Ðr1ps - Nov 1, 2015

Not really familiar with regex.
I need to get the numbers from 01 to 99. Any ideas? Thanks.


* - Who Soup - Nov 1, 2015

(Nov 1, 2015 01:30 PM)Ðr1ps Wrote:  Not really familiar with regex.
I need to get the numbers from 01 to 99. Any ideas? Thanks.

what do you mean "get the numbers"

why not just do a simple loop

dim los as new list of string
for i as integer = 1 to 99 step 1
console.writeline(i)
los.add(i)
next

end


* - Ðr1ps - Nov 1, 2015

(Nov 1, 2015 01:33 PM)Who Soup Wrote:  what do you mean "get the numbers"

why not just do a simple loop

dim los as new list of string
for i as integer = 1 to 99 step 1
console.writeline(i)
los.add(i)
next

end

How do you know what language I'm writing this in lol.
I just need the regex to allow from the said numbers.


* - +Haze - Nov 1, 2015

(Nov 1, 2015 01:33 PM)Who Soup Wrote:  what do you mean "get the numbers"

why not just do a simple loop

dim los as new list of string
for i as integer = 1 to 99 step 1
console.writeline(i)
los.add(i)
next

end

How can you suggest a solution when you don't even know the context of ops question?


* - EmptyRedData - Nov 1, 2015

Just googling your exact question "regex 01 to 99", I got several good answers, mostly from stack overflow.

https://stackoverflow.com/questions/11218985/mvc-regex-to-validate-numbers-as-00-99


Also, checking the regular expression website for numeric ranges: http://www.regular-expressions.info/numericranges.html


* - +Haze - Nov 1, 2015

@Drips, show me what you're trying to match specially. For Regex, numbers is usually, \d or [0-9], then you'd need quantifiers.

So, \d+ would match one or more digits. \d{1,2} would match any one or two digit number etc. Like I said its better if you show us the pattern you're trying to match or what you're trying to accomplish all together.


* - Ðr1ps - Nov 1, 2015

(Nov 1, 2015 01:44 PM)+Haze Wrote:  @Drips, show me what you're trying to match specially. For Regex, numbers is usually, \d or [0-9], then you'd need quantifiers.

So, \d+ would match one or more digits. \d{1,2} would match any one or two digit number etc. Like I said its better if you show us the pattern you're trying to match or what you're trying to accomplish all together.

It's pretty simple actually, a couple examples:
(09)
(21)

Including the parenthesis but I assume I can just add it on the outside and include the regex inside.


* - +Haze - Nov 1, 2015

In that case


\(\d{1,2}\)

would work just fine.


* - Ðr1ps - Nov 1, 2015

(Nov 1, 2015 01:48 PM)+Haze Wrote:  In that case


\(\d{1,2}\)

would work just fine.

To understand this, d is for integer like in C?
Also, what are the brackets for exactly?


* - +Haze - Nov 1, 2015

Here you go.
http://www.codeproject.com/Articles/9099/The-Minute-Regex-Tutorial


* - Ðr1ps - Nov 1, 2015

(Nov 1, 2015 01:53 PM)+Haze Wrote:  Here you go.
http://www.codeproject.com/Articles/9099/The-Minute-Regex-Tutorial

Will have a look, thanks