Link to home
Create AccountLog in
Avatar of XK8ER
XK8ERFlag for United States of America

asked on

vb.net match all with regex

hello there,
I would like to match all of the images that have been downloaded between 120 and 150.. something like this but its not working..

<SPAN class=fcg>[120-150].*?downloaded images</SPAN>

this is the original code..

<SPAN class=fcg>2 downloaded images</SPAN>
<SPAN class=fcg>130 downloaded images</SPAN>
<SPAN class=fcg>25 downloaded images</SPAN>
<SPAN class=fcg>552 downloaded images</SPAN>
<SPAN class=fcg>6592 downloaded images</SPAN>
<SPAN class=fcg>64 downloaded images</SPAN>
Avatar of cyberkiwi
cyberkiwi
Flag of New Zealand image

You need the pattern "1([2-4]\d|50)" and the bits around it
It must start with a "1"
The the next part is an OR between
    (1) "[2-4]\d", i.e. 2x through 4x (20-49) and
    (2) "50" exactly 50
Avatar of XK8ER

ASKER

ok to make it more simple im trying to match the whole

<SPAN class=fcg>*** downloaded images</SPAN>

and any number above 100
if you want to match be between 100-999 use this
<SPAN class=fcg>([1-9]\d{2}).*</SPAN>

or any number greater than or equal or above 100
<SPAN class=fcg>([1-9]\d{2,}).*</SPAN>

Avatar of XK8ER

ASKER

ohh man this is so hard.. that code works perfectly fine.. but how can I make 75 and above or 50 and above etc..?
regex is not a arithmetics-based pattern, so you can't say... this part is between this and that number
You will notice throughout your questions here and php, that the trick always involves elaborately dealing with the number as a text pattern or a series of them
If you have a specific pattern in mind (for that is what regular expressions is all about), we can help, but if you want to keep asking different questions (numeric based), then this may not be the right way to do it.
Avatar of XK8ER

ASKER

yeah but maybe if you tell me which chars I need to change for that I can do like

100 and above
80 and above
60 and above

I would really appreciate it..
>100 and above
Does that include up to 999? or 1000, 100000?

80-99
regex: [89]\d    << 8 or 9, followed by one digit

60+ Any valid number
regex: ([6-9]\d|1\d{2,})     << either (1) 60-99, as above, or (2) "1" followed by 2-or-more digits
100+ covered by bansidhar above
SOLUTION
Avatar of bansidhar
bansidhar
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of XK8ER

ASKER

yes I understand and I thank you guys for answering all the questions.. I got all the ones that I needed but lets say I need a few more how do I make new ones there is no translator for this..
suggestion: don't use regex unless you are very comfortable with it. it is like a very sharp 2 edged sword. use with care.
try using some tools, like regexbuddy (never used came across googling)
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of XK8ER

ASKER

thanks guys.. you are the best!
thanks for pointing out the error. typing from my mobile
actually both above 50 and above 75 has this error

have to change
\d{3,}
to
[1-9]\d{2,}

but here also you can fool it by sending 09999 and it won't recognize it. if you want to take into account all the possibilities the equation will become very complex (so omitting it). If you want i can make one but first have to get to a computer.