From: Axel Etzold Date: 2007-05-15T04:46:47+09:00 Subject: Re: Regex problem, probably simple Dear Jim, assuming that you have the following in webpage "a0.html": ... ... ... , you can run the following script: my_page=IO.readlines("a0.html").to_s r1=// r2=/(?=]+>)/ r3=/]+)>/ text=my_page.split(r1) text2=text[1..-1].join.split(r2)[1] ref=r3.match(text2) p 'the first link was : ' + ref[1] I read in the entire page into a string my_page, split that into an Array at the first occurrence of regexp r1, join it back again into a string, then split that into an array using regexp r2, which keeps the delimiter (of form ]+> ...that's what the (?= .. ) syntax is for) , rather than dropping it, as in the first split. If there is text before the first occurrence of r3, you'll find it in the first element of the splitted string: text[1..-1].join.split(r2)[0], and the first occurrence of r3 is in the second element text2. If you want more information about Regexps, you'll might find this helpful: http://www.regular-expressions.info/ruby.html Best regards, Axel -- GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS. Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail