mIRC Homepage
Posted By: lerpicus Using $regsubex to strip 'tags' - 12/12/07 09:58 PM
The following code posted elsewhere on this site strips out html tags
Code:
alias hst {  return $regsubex($1,/<.+?>/g,) }

I have modified it as follows,
Code:
alias braces {  return $regsubex($1,/{.+?>}g,) }

having renamed it and replaced '<' & '>' with '{' & '}'.

The new alias performs a similar function to that of $hst, but strips out 'tags' delimited by curly brackets instead of tags delimited by angle brackets. However, the alias fails to perform as I would wish when there is a space between the opening '{' and the contents of the 'tag'. Any advice would be appreciated.
Posted By: Mpdreamz Re: Using $regsubex to strip 'tags' - 12/12/07 11:57 PM
Code:
//echo -a $regsubex({he llo} you {} there {tag} whatsup?,/{.*?}/g,)
Posted By: lerpicus Re: Using $regsubex to strip 'tags' - 13/12/07 03:53 AM
As simple as that? Thankyou.
Posted By: lerpicus Re: Using $regsubex to strip 'tags' - 13/12/07 04:21 AM
oh dear. $Maybe I congratulated you too soon.
Your example works fine as an alias, but when called as a custom identifier I still have the same problem.
eg. if i have the following alias
Code:
alias braces {  return $regsubex($1,/{.*?>}g,) }
then this input
Code:
//say $braces({he llo} you {} there {tag} whatsup?)
it works fine.
But make the input
Code:
//say $braces({he llo } you {} there {tag} whatsup?)
and an error is returned.

mIRC doesn't handle spaces very well, does it?
Posted By: Mpdreamz Re: Using $regsubex to strip 'tags' - 13/12/07 11:45 AM
you seem to have modified the regex a tad:
Code:
alias braces return $regsubex($1-,/{.*?}/g,)


However your still going to have issues with:

Code:
//echo -a $braces({ he llo } you {} there {tag} whatsup?)


This is due the t "}" with spaces around it makes mIRC think it needs to close down.

i.e
Code:
//tokenize 32 a b c d e f g { if ($1-) echo -a $1- }

is the same as
Code:
//tokenize 32 a b c d e f g | if ($1-) echo -a $1-


So passing the parameters yourself is going to be crude:

Code:
//tokenize 32 $({,) a $(},) <-- is that being stripped ? | echo -a $braces($1-) orginal: $1-


but whenever "{ tag }" is put in an $ident by mIRC itself (i.e in $1- in on text event or $did() in a dialog) you wont have to escape { and }

i.e:
Code:
//tokenize 32 $({,) a $(},) <-- is that being stripped ? | var %x = $1- | echo -a $braces(%x) 


Hope that helps smile


Whats actually funny about "}"
Code:
alias tr { tokenize 32 $({,) a $(},) <-- is that being stripped ? } set -l %x $1- } echo -a %x }


this works "fine" all be it you have to use set -l because it wont be sent in the aliases scope but in the main mIRC's scope , just as /var doesn't work in the editbox of mIRC.

Code:
alias tm {
  var %x = $$1 * 3
} return %x


also works as expected this is because mIRC doesn't really parse by { } i.e it wont check while parsing a script if the correct ammount are used. It just keeps streaming the alias untill it can't no more.
Posted By: lerpicus Re: Using $regsubex to strip 'tags' - 16/12/07 07:58 PM
Yes. I did 'did' modify the tag frown

Thanks again smile
© mIRC Discussion Forums