So I have the expression rule that will abbreviate a string. Thoughts on how to improve?
/*Replace all special characters with spaces*/ /*Replace extra spaces with since space*/ /*Wrap numbers in spaces*/ /*Split words and number sets into array*/ /*ForEach item in array grab number or first letter of word*/ /*Join what is left, upper case string and grab left 50 characters*/ with( local!nospecialcharacters: regexreplaceall( "[^\w\s]", ri!in, " " ), local!extraspaceswithsinglespace: regexreplaceall( "\s+", local!nospecialcharacters, " " ), local!numberwrapper: if(regexmatch("\d+",local!extraspaceswithsinglespace), regexinsertmatchmarkers( "\d+", local!extraspaceswithsinglespace, " ", " ", false ), local!extraspaceswithsinglespace ), local!segments: split( regexreplaceall( "\s+", local!numberwrapper, "|" ), "|" ), local!keepers: a!forEach( local!segments, if( isnull( fv!item ), null, if( not( isnull( tointeger( fv!item ) ) ), fv!item, if( fv!item = " ", null, if( regexmatch("^[a-zA-Z]+$", fv!item ), left( fv!item, 1 ), null ) ) ) ) ), left( upper( joinarray( local!keepers, "" ) ), 50 ) )
Discussion posts and replies are publicly visible
As a thought experiment, it's pretty cool. Compared to a similar special character function I had to deal with in the past, it's pretty speedy (though we also had to preserve special characters via lower-ascii equivalents). Our target was 4,000 characters in under 100ms. As for the potential utilities I could see this type of thing being used for, it's a bit flawed since it wipes a away an average of >80% of its data in the output. What's it for?
I'm curious to know how an equivalent reduce() function performs for local!keepers.