That's what test2.tcl in this [L1 ] "Regular Expressions" [L2 ] column does.
Also see the fileevent page.
Category GUI