# mirc_strip [switches] <text>
# version:
# v1.0
proc mc:sc:mirc_strip {{args ""}} {
mc:sc:badargs $args 1 7 "?switches? text"
set switches ""
for {set i 0} {[string match -* [set arg [lindex $args $i]]]} {incr i} {
if {![regexp -- {^-(all|bold|color|reverse|underline|-)$} $arg -> switch]} {
set valid "-all -bold -color -reverse -underline {or --}"
error "bad switch \"$arg\": must be [join $valid ", "]"
}
if {$switch == "-"} {
incr i
break
}; lappend switches $switch
}
if {$switches == ""} {set switches all}
set arg [lindex $args $i]
mc:sc:badargs [lrange $args $i end] 1 1 "?switches? text"
set all [expr {([lsearch -exact $switches all] >= 0) ? 1 : 0}]
set list ""
if {$all} {
set list [list \002 "" \017 "" \026 "" \037 ""]
} else {
if {[lsearch -exact $switches bold] >= 0} {lappend list [list \002 ""]}
if {[lsearch -exact $switches plain] >= 0} {lappend list [list \017 ""]}
if {[lsearch -exact $switches reverse] >= 0} {lappend list [list \026 ""]}
if {[lsearch -exact $switches underline] >= 0} {lappend list [list \037 ""]}
}
if {$all || ([lsearch -exact $switches color] >= 0)} {
regsub -all -- "\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $arg "" arg
}
set arg [mc:sc:replace -- $arg [join $list]]
return $arg
}
But when I put the text into a mysql datbase some strings still have a in them. Could someone help me with this? What did I forget to remove form the string?
Benpsycho wrote:when I put the text into a mysql datbase some strings still have a in them. Could someone help me with this? What did I forget to remove form the string?
That "" is the mIRC control code for plain text. I think the proc you pasted is a bit overkill if you want to strip all control codes. Try this instead: