Christmas colors
Posted by Rustynails
Wednesday, December 21, 2005
Description: Make your text look like christmas!

Usage: $c(text) or /c <text>
This is a bit long because unlike most scripts, this allows commas to be used instead of totally avoiding them...

alias c {
  if (!$isid) {
    var %r = 1
    while (%r <= $len($1-)) {
      var %q = %q $+ $iif($mid($1-,$calc(%r - 1),1) == $chr(32),$chr(32),) $+ $iif($calc(%r % 2) == 0,[^K]04,[^K]03) $+ $mid($1-,%r,1)
      inc %r
    }
    say [^B] $+ %q
  }
  else {
    %x = 1
    while (%x <= $0) {
      var %r = 1
      while (%r <= $len($eval($+($chr(36),%x),2))) {
        var %q = %q $+ $iif(%r == 1,$chr(32),$iif($mid($eval($+($chr(36),%x),2),$calc(%r - 1),1) == $chr(32),$chr(32),)) $+ $iif($calc(%r % 2) == 0,[^K]04,[^K]03) $+ $mid($eval($+($chr(36),%x),2),%r,1)
        inc %r
      }
      var %q = %q $+ $iif($mid($($+($chr(36),%x)),$calc(%r - 1),1) == $chr(32),$chr(32),) $+ $iif($calc(%r % 2) == 0,[^K]04,[^K]03) $+ $chr(44)
      inc %x
    }
    return [^B] $+ $right($left(%q,-1),-1)
  }
}
Subject line
Posted by HellRaz0r
Tuesday, September 12, 2006 11:29pm PDT
regex supports comma's but you have to store them in a variable then put that variable into regex,

//var %str some,text,here | echo -a $regsubex(%str,/(.)/g,[^K] $+ $r(3,4) $+ \t)

like so.
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world