どのように変数を常に50文字後に分割することができますか?変数内のtclの長さ
のでsplittは50 charachters
set length [::textutil::adjust $text -length 50 -strictlength true]
よろしく
編集した後にのみ、新しい行にあります。
入力が
LaRochelle, a former pirate captain, is caught by the British. To get his
ship back, he works as a spy against other pirates, first of all Blackbeard
and Providence. He works on some ships, crossing the Caribbean sea, with the
intention
set pieces [regexp -all -inline {.{1,50}} $Plot]
set 0 [lindex [lindex $pieces 0] 0]
set 1 [lindex [lindex $pieces 1] 1]
putnow "PRIVMSG $channel :$0"
出力された変数$プロットで、このテキストでありますのみ:
<testbot> LaRochelle,
<testbot> British.
残念ながら、もはや..
あなたはあなたが求めるものを手に入れます。 'regexp'の呼び出しはあなたのテキストを複数の50文字に分割します。次に、最初の作品の最初のアイテムを尋ね、2番目の作品の2番目のアイテムの "LaRochelle"を取得し、 "British"を取得します。あなたは何か他のことを期待していましたか? –
はい0-50個、LaRochellaだけでなく、これは11個です。残りはどこですか? 50ピースはこれです:以前の海賊船長のLaRochelleがキャッチされました – revoque
'pieces'変数にあるものを調べるか、' lindex $ pieces 0'と 'lindex $ pieces 1'という式をそれぞれ使用してください。例えば、 'lindex $ pieces 0'は' 'LaRochelle ''(これは元の海賊船長)に' 'によって捕獲されます。これは' 'pieces'のリストの最初の項目です。' pieces'はあなたのテキストからの断片のリストであり、それぞれ最大50文字です。 –