Martin DeMello
3/3/2005 8:01:00 AM
Svend-Erik Kjær Madsen <sv-erik@stofanet.dk> wrote:
> Hi
> I have a file, only containing html links, I read the file in a
> variable, an then I want to sort all that differs from htmltags.
>
> My Regexp string is: (?-mix:<("[^"]*"|'[^']*'|[^ '">])*>)
>
> Is it possible to sort the string, without putting it all in an array first?
>
> If so, can anyone give me a hint, how to solve the problem.
Do you mean you want to sort the lines of the file, but only sort based
on the text not in the tags? If so, try (not tested!)
lines = IO.readlines(inputfile)
sorted = lines.sort_by {|i| i.gsub /<.*?>/, ""}
martin