Textinfo percent/bold/underline....

By juhapuha on Aug 23, 2008

works like: //echo -a $text(sometext).bold/caps/bold/reverse/color
Would be useful for bots etc :)

alias text {
  if (!$istok(caps|bold|underline|reverse|color,$prop,124)) || (!$prop) || (!$1) return
  if ($prop == caps) return $calc($regex($1-,/[A-ZÄÖÅÜ]/g) * 100 / $len($strip($1-)))
  elseif ($prop == bold) || ($prop == underline) || ($prop == reverse) {
    var %i 1,%z 0,%r $iif($prop == bold,$regex($1-,/\002([^\002]+)\002?/g),$iif($prop ==  underline,$regex($1-,/\037([^\037]+)\037?/g),$regex($1-,/\026([^\026]+)\026?/g)))
    while (%i <= %r) { inc %z $len($strip($regml(%i)))) | inc %i }
    return $calc(%z * 100 / $len($strip($1-)))
  }
  elseif ($prop == color) {
    var %i 1,%z 0,%r $regex($1-,/\003\d\d?(.\d\d?)?([^(\003\d\d?(.\d\d?)?)?]+)/g)
    while ($regml(%i)) { if ($left($regml(%i),1) != $chr(44)) { inc %z $len($strip($regml(%i)))) } | inc %i }
    return $calc(%z * 100 / $len($strip($1-)))
  }
}

Comments

Sign in to comment.
EL   -  Aug 23, 2008

Rofl well u dont have to change it on our accounts ;p we jsut made suggestions of different ways of doin it.`-.-´

 Respond  
juhapuha   -  Aug 23, 2008

-- ><

I will update the snippet!
so you can get percent of colour/underline/reverse/caps ! and with regex because you seem you love it
At first i want to make the snippet simple so even beginners could understand it.

 Respond  
napa182   -  Aug 23, 2008

going along with that you can do it like this as well

alias caps { return $calc($regex($1-,/[A-Z]/g)/$len($1-)*100) }
 Respond  
EL   -  Aug 23, 2008
alias caps { return $round($calc($regex($1-,/[A-Z]/g) / $regex($1-,/[A-Z]/gi) * 100),0) }

Both return the same.`-.-´

 Respond  
juhapuha   -  Aug 23, 2008

It works fine :>
even though none of text would be caps :)

 Respond  
vaseline28   -  Aug 23, 2008

Just got a couple of things, to set a variable, you don't need an =, you can just do:

var %i 1

Instead of:

var %u = $calc(%u + 1)

Just declare %u as 0 at the start and then do:

inc %u

Otherwise the script won't necessarily return anything if none of the text is caps.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.