$iscaps

By Saeed on Sep 28, 2007

This is a simple code that returns the percentage of capital and non-capital letters in a line of text.

For example:

If I were to type: //echo -a $iscaps(III).get it would return %100. If I were to type: //echo -a $iscaps(iII).non it would return %33.3

The syntax is either: $iscaps(string).get or $iscaps(string).non

;--------------------------
;- $iscaps - Saeed * 2007 -
;--------------------------
;--- Usage ----------------
;--- $iscaps(string).get --
;--- $iscaps(string).non --
;--------------------------

alias iscaps { 
  if ($isid) { 
    if ($prop = get) { 
      if ($2-) { 
        var %i $regex($2-,/[A-Z]/g), %t = $len($2-)
        return $calc(%i / %t * 100)
      }
    }
    if ($prop = non) { 
      if ($2-) { 
        var %i = $regex($2-,/[^A-Z]/g),%t = $len($2-)
        return $calc(%i / %t * 100) 
      }
    }
  }
}

Comments

Sign in to comment.
KuTsuM   -  Oct 03, 2007

Ignore the above question: You should use the prop parameter ($prop)

 Respond  
KuTsuM   -  Oct 03, 2007

Why do you need to declare \"get\"? Good regex example.

 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.