Regular Expression Acronym Replacer

By DarthReven on May 05, 2006

Finally i made an acronym replacer that uses regular expressions to do the job or checking and replacing acronyms. To use this alias follow the directions below.

;Regular Expression Acronym Replacer
;Script By: DarthReven
;-----------------------------------
;To use this addon add the alias to any "ON INPUT" event
;Then add each acronym in this format:
;/hadd REG_ACRO_TABLE <acronym> <acronym meening>
;EX: /hadd REG_ACRO_TABLE lol laughing out loud
;------------------------------------

alias REG_ACRO {
  VAR %REG_ACRO_INPUT $1-, %REG_ACRO_TOK $HGET(REG_ACRO_TABLE,0).DATA, %REG_ACRO_TEMP, %REG_ACRO_OUTPUT
  WHILE (%REG_ACRO_TOK) {
    IF ($REGEX(REG_ACRO_EX,%REG_ACRO_INPUT,$+(/\b,$CHR(40),$HGET(REG_ACRO_TABLE,%REG_ACRO_TOK).ITEM,$CHR(41),\b/ig))) {
      %REG_ACRO_TEMP = $REGSUB(%REG_ACRO_INPUT,$+(/\b,$CHR(40),$HGET(REG_ACRO_TABLE,%REG_ACRO_TOK).ITEM,$CHR(41),\b/ig),$HGET(REG_ACRO_TABLE,%REG_ACRO_TOK).DATA,%REG_ACRO_OUTPUT)
      %REG_ACRO_TEMP = $REGSUB(%REG_ACRO_OUTPUT,$+(/\b,$CHR(40),$HGET(REG_ACRO_TABLE,%REG_ACRO_TOK).ITEM,$CHR(41),\b/ig),$HGET(REG_ACRO_TABLE,%REG_ACRO_TOK).DATA,%REG_ACRO_INPUT)
    }
    DEC %REG_ACRO_TOK
  }
  TOKENIZE 32 $IIF(%REG_ACRO_OUTPUT,$v1,%REG_ACRO_INPUT)
  RETURN $+($UPPER($LEFT($1,1)),$MID($1-,2))
}
ON *:START: { hmake REG_ACRO_TABLE 1000 | hload REG_ACRO_TABLE REG_ACRO_TABLE.HSH }
ON *:EXIT: { hsave -o REG_ACRO_TABLE REG_ACRO_TABLE.HSH }

Comments

Sign in to comment.
DarthReven   -  May 07, 2006

Edit: removed the $replacecs w/ fix in the regular expression thanks to QuickStep

 Respond  
QuickStep   -  May 06, 2006

The $replacecs looks weird and out of order, I don\'t really see why you hard coded an acronym in your code. You say: \"Note: The acronyms thank you and no problem are already inputed in the main part of the alias do to regex\'s case sensitive nature\". Well, the truth is, regex is as case (in)sensitive as you specify it to be. If you use the /i switch, it will make the check case insensitive, which is probably what you are looking for.

 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.