This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

regexp X times

Old posts that have not been replied to for several years.
Locked
t
t3ch^
Voice
Posts: 16
Joined: Sat Dec 27, 2003 7:19 pm

regexp X times

Post by t3ch^ »

I got this code

Code: Select all

<a href="/Sections/Genres/Fantasy/">Fantasy</a> / <a href="/Sections/Genres/Adventure/">Adventure</a> / <a href="/Sections/Genres/Action/">Action</a>
This can vary in number and genres but the code is still the same.
How would i fetch all betwean > < ?
i figured somthing like this

Code: Select all

foreach [regexp -nocase {<a href=\"/Sections/Genres/[a-z]*/\">([a-z]*)</a>} $string string match] $string {
puthelp "NOTICE $nick :$match"
}
with this i get, in this case

Code: Select all

Fantasy
Fantasy
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: regexp X times

Post by user »

Check out the -all and -inline options (http://tcl.tk/man/tcl8.4/TclCmd/regexp.htm) and make sure you know how they work before writing the loop (you can't avoid reporting the entire match, so you need a variable for that value which will be discarded in most cases)
Have you ever read "The Manual"?
Locked