'In tcl how can I group signals and put them in a particular category

In tcl how can I group signals and put them in a particular category I have a few signals

    ahb_hdata
    apb_pdata_out
    axi_reps_n
    apb_req_n
    ahb_reset_n
    apb_pwrite
    ahb_haddr
    axi_ready_in
    axi_trans
    

I wanted to group the signals in this format

ahb:         apb:             axi:
 ahb_hdata      apb_pdata_out   axi_trans
 ahb_reset_n    apb_pwrite      axi_reps_n
 ahb_haddr      apb_req_n       axi_ready_in

So far I was able to search whether substring is present or not, But here I have many substrings that are to be searched and had to group them, I didn't how to group them and put them under a particular category

set string "ahb_hdata, apb_pdata_out, axi_reps_n, apb_req_n, ahb_reset_n, apb_pwrite, 
ahb_haddr, axi_ready_in, axi_trans "

set substring "ahb"
  if {[string first $substring $string] != -1} {
puts "$substring"
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source