Syntax: $stripwm(text,wildmatch).[frN]
text: is the text you wish to strip.
wildmatch: the wildmatch you wish to strip. The wildmatch character is "" (without the quotes).
"ad" will match "abcdefg" but also "1234abcdefg"
so unlike wildmatching ON TEXT "ad" means a followed by zero or more characters up to the last d it finds anywhere in the string
and not a string that starts with a followed by 1 or more characters followed by a d.
therefor the match "a" will completely strip the text "abcdefg"
Properties:
-f : this makes stop at the First character it finds after instead of the last
//echo -a$stripwm(aq hello aq,aq).f
returns "hello" instead of stripping the entire text.
-rN : makes it strip everything but the matches it makes and returns a tokenized list of all the matches.
//echo -a$stripwm(aq hello aq hello arghq,aq).fr
returns "aq,aq,arghq"
//echo -a $stripwm(aq hello aq hello arghq,a*q).r
returns "aq hello aq hello arghq"
N stands for the ascii delimiter for the return tokens
//echo -a $stripwm(aq hello aq hello arghq,a*q).fr46
returns "aq.aq.arghq"
if not specified it will use $chr(44) (,) by default.
In short
alias stripwm {
if ((!$1) || (!$2)) || (!$isid) return
var %r = $+(/,$chr(40),$regsubex($regsubex($regsubex($regsubex($2,/(\.|\?|\+|\[|\]|\^|\$|\\)/g,\\t),/\*$/,*$),/^\*/,^*),/\*/g,$+(.*,$iif(f isin $prop,?))),$chr(41),/g)
if (r isin $prop) {
var %t = $regex(stripwm,$1,%r) , %m = $regml(stripwm,0) , %x = 1 , %return
while (%x <= %m) {
%return = $instok(%return,$regml(stripwm,%x),%x,$iif($regsubex($prop,/\D/g,),$v1,44))
inc %x
}
return %return
}
return $regsubex($1,$+(%r,g),)
}