PDA

View Full Version : regular expressions


vod
09-28-2003, 06:25 PM
Can anyone point me to a sane and simple regular expression lib i can use in vc++ 7.x

I just wanta be able to do like
.*something.*somethingelse.*boo{.*}.*etc

where the one in brackets is the group/expression i wanta extract, most ive seen id have to know that the 4th match was the one i wanted...i just wanta pass a string and have a value pulled out without knowing which num match it will be...if that makes sence..heh

Mouton
09-28-2003, 06:29 PM
I doubt there's a sane and simple regexp lib for vc++...
I use re_lib. not easy to play with, but working great.

btw, it's () not {} to fetch values.

not sure i understand what ur trying to do though...
in fact, i'm sure i don't! ;)

vod
09-28-2003, 09:30 PM
Originally posted by Mouton
I doubt there's a sane and simple regexp lib for vc++...
I use re_lib. not easy to play with, but working great.

btw, it's () not {} to fetch values.

not sure i understand what ur trying to do though...
in fact, i'm sure i don't! ;)

i finally got greta to compile (that unimportant file i didnt link was important afterall), but i cant get it to do what i want, i can get it to extract the whole match but not part of it...
in perl compat yea () is grouping set,, i know of some that use {} for sets though

anyway, say i have
This random >> hello kitty << boo bob random random
i wanta extract first word in >><<
so i do like ">>.* .*<<" but my match will be ">> hello kitty <<" and not just "hello", id have to explicatly say i want use the first one (like perl it would be $1 i think), i sware there is some way to say "match this but dont count it"
im not sure that makes any more sence than what i posted before, heh

oh well, **** the regular expressions anyway, ill do it staticly

Mouton
09-29-2003, 08:07 AM
text: >> hello kitty << boo bob random random

regexp: >> ([^ ]*) .* << .*

\1 will give u the first word after >> all the time, since the match is only what's between ().

FTPServerTools
09-29-2003, 09:45 AM
Download regex.c or regex.cpp from the web. I find it overdone tho, you can use simple regex from the unzip.c source codes.

vod
09-29-2003, 08:45 PM
Originally posted by FTPServerTools
Download regex.c or regex.cpp from the web. I find it overdone tho, you can use simple regex from the unzip.c source codes.

ah, its all good, i dont think what i want is posiable, but its ok cause the way i did it is faster anyway. i imported the greta regex lib, its slightly big but pretty damn fast.