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.

Substraction of strings

Old posts that have not been replied to for several years.
Locked
User avatar
ex
Voice
Posts: 14
Joined: Wed May 18, 2005 11:04 pm
Location: Chicago

Substraction of strings

Post by ex »

To make it short: i want a routine which handles strings like giving chanlevs in quakenet.

for example:

user has: ao
i type: /msg q chanlev #chan #auth -o+v

result: user has +av

is there a possibility to reach that with regex? can anyone provide a regex solution?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

proc chflags {flags changes} {
	set add -1
	foreach c [split $changes ""] {
		switch -- $c {
		"+" {set add 1}
		"-" {set add 0}
		default {
			if {$add < 0} {error "flag changes must begin with +/-"}
			set i [string first $c $flags]
			if {$add > 0} {
				if {$i == -1} {append flags $c}
			} {
				if {$i != -1} {set flags [string replace $flags $i $i]}
			} 
		}}
	}
	return $flags
}
Locked