$nohtml()
I thought this was a cool way of doing it.
Question:
Do I need that else? I don't think I do ;s.
alias nohtml {
unset %b
var %a 1
while (%a <= $len($1-)) {
if ($mid($1-,%a,1) == $chr(60)) { inc %c }
if ($mid($1-,%a,1) == $chr(62)) { dec %c }
else { set %b %b $+ $iif(%c < 1,$iif($mid($1-,%a,1) == $chr(32),$str($chr(32),2),$mid($1-,%a,1))) }
inc %a
}
return $iif(%b,%b,$false)
}
This is just an example of using $regsubex and replacing html tags with $chr(32) "space".
Elaborate Example:
alias html.test {
var %x $1-
if (!$0) %x = $?="Sample HTML?"
if (!%x) %x = This is a test.
echo -a Test: $regsubex(%x,/(^[^<]>|<[^>]>|<[^>]*$)/g,$chr(32)) - Tags Removed: $regml(0)
}
It can be shortened to:
alias rm.html return $regsubex($$1-,/^[^<]>|<[^>]>|<[^>]*$/g,)
/echo -a $rm.html(Hello World!)
Produces: Hello World!