As I won't remember the trick in 6 months - and as I don't want to invest the time to tell it every colleague, I tried to set up a custom function:
Add Custom Functions(
New Custom Function(
"test",
"countWord",
Function( {myString, myWord},
If( Length( myWord ) > 0,
Return( (Length( myString ) - Length( Substitute( myString, myWord, "" ) )) / Length( myWord ) ),
Return( 0 )
)
),
<<Description( "count words in a String" ),
<<Example( Expr( test:countWord( "cat, dog, Dogs, cat, Cat", "cat" ) ) )
)
);
t0=hptime();
dt_long << new column("new", set each value(test:countWord(:Lot_Wafer Label,"xxx")));
Write ("via custom function:\!t",(hptime() - t0)/1000000,"s\!n");
unfortunately:
How do I have to adjust the custom function to make it as fast as the original version by @ian_jmp ?
[removing the If(...) helps a bit - but how to get it < 1s?]