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.

split large lines into multiple for easier reading

Help for those learning Tcl or writing their own scripts.
Post Reply
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

split large lines into multiple for easier reading

Post by simo »

greetings ,

how would we split large lines line this into multiple to make it easier to read ?

Code: Select all


if {[regexp -nocase {\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|\.ip|$} $host]} { do stuff }


User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: split large lines into multiple for easier reading

Post by CrazyCat »

Can you post an example of line you want to split ?
And your regexp is... weird.
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Re: split large lines into multiple for easier reading

Post by simo »

the line i just posted is an example of a long line of code id like to split in 2 or 3 lines

i tried like this but not sure if its proper :

Code: Select all

 

                if {[regexp -nocase {\.5\.IP|\.59\.IP|\.39\.IP|\.49\.IP|\.101\.IP|\.103\.IP|\.110\.IP|\.111\.IP|\.116\.IP|\.154\.IP|\.158\.IP|\.167\.IP|\.182\.IP|\.202\.IP|\.223\.IP|\.PK|\.virginm\.net|contaboserver\.net|alshamil\.net\.ae|shawcable\.net|cable\.virginm\.net|cable\.rogers\.com &&
                \.2\.ip|\.5\.ip|\.37\.ip|\.39\.ip|\.46\.ip|\.49\.ip|\.51\.ip|\.59\.ip|\.72\.ip|\.101\.ip|\.103\.ip|\.110\.ip|\.111\.ip|\.116\.ip|\.117\.ip|\.119\.ip|\.124\.ip|\.173\.ip|\.139\.ip|\.195\.ip|\.203\.ip|\.212\.ip|\.154\.ip|\.158\.ip|\.167\.ip|\.175\.ip|\.182\.ip|\.185\.ip|\.202\.ip|\.213\.ip|\.223\.ip|\.verizon.net|\.comcast.net|\.38\.ip|\.ca|\.ae$} $host]} {  
                   if {![ischanban $host $chan]} {  set bmask $host } 
                   
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: split large lines into multiple for easier reading

Post by CrazyCat »

Oh, I didn't underdstand you mean "wrapping" your code.
Splitting a regexp is a bad idea as you don't know how cr/lf could be interpreted, but you can have a look on https://stackoverflow.com/questions/636 ... iple-lines
s
simo
Revered One
Posts: 1107
Joined: Sun Mar 22, 2015 2:41 pm

Re: split large lines into multiple for easier reading

Post by simo »

thanks CrazyCat , i tried it like this and it seems to work but im not sure if its proper i kinda followed the suggestion on the link you provided.

Code: Select all


             set banmask "[lindex [split $uhost "@"] 1]"

                if {[regexp -nocase {\.5\.IP|\.59\.IP|\.39\.IP|\.49\.IP|\.101\.IP|\.103\.IP|\.110\.IP|\.111\.IP|\.116\.IP|\.154\.IP|\.158\.IP|\.167\.IP|\.182\.IP|\.202\.IP|\.223\.IP|\.PK|\.virginm\.net|contaboserver\.net|alshamil\.net\.ae|shawcable\.net|cable\.virginm\.net|cable\.rogers\.com|
                \.2\.ip|\.37\.ip|\.812\.ip|\.39\.ip|\.46\.ip|\.51\.ip|\.59\.ip|\.72\.ip|\.116\.ip|\.117\.ip|\.119\.ip|\.124\.ip|\.173\.ip|\.139\.ip|\.195\.ip|\.203\.ip|\.212\.ip|\.175\.ip|\.185\.ip|\.202\.ip|\.213\.ip|\.verizon.net|\.comcast.net|\.38|\.ca|\.ae$} $banmask]} {  
                   if {![ischanban $banmask $chan]} {  set bmask *!*@$banmask } 
                   } else { set bmask "*!*@[lindex [split $ZbanmaskQ "."] 0].[join [lrange [split $banmask .] 1 end] .]" }


Post Reply