**Here is a custom function for PatternCount as PatternCount sometimes doesnot work for operators.
PatternCountNew(text;searched;count1;repeat0)
text – the text to be formatted.
searched – the text which is to be searche for its number of occurances.
count1 – 1 (always)
repeat0 – 0 (always)
Supporting custom function :-
Comparing(text;searched;textPos;count1)
text – the text to be formatted.
searched – the text which is to be searche for its number of occurances.
textPos – Position (number) of searched text from the original text.
count1 – 1 (always)
PatternCountNew(text;searched;count1;repeat0)
———————————————————————————
Let (
[
text1 = text;
letter = Middle ( text1 ; count1 ; 1 );
repeat0 = If ( letter = Left ( searched ; 1 ) and Comparing(text1;searched;count1;1) = Length ( searched ) ;
repeat0 + 1 ;repeat0 );
count1 = If ( letter = Left ( searched ; 1 ) and Comparing(text1;searched;count1;1) = Length ( searched ) ;
count1 + Length ( searched ) ;count1+1 )
];
If ( count1 > Length ( text1 ) ; repeat0 ; PatternCountNew(text1;searched;count1;repeat0) )
)
———————————————————————————
Comparing(text;searched;textPos;count1)
———————————————————————————
Let (
[ text1 = text ;
value = searched;
letter = Middle ( text1; textPos ; 1 );
searchedLetter = Middle ( searched; count1 ; 1 )
];
Case (
count1 > Length ( value ) ; count1 -1 ;
letter = searchedLetter ; Comparing(text1;value;textPos+1;count1+1);
count1 – 1
)
)
———————————————————————————
************************************************************************************************************
**Here is another custom function for PatternCount of Exact text as PatternCount is case insensitive.
PatternCountExatc(text;searched;count1;repeat0)
text – the text to be formatted.
searched – the text which is to be searche for its number of occurances.
count1 – 1 (always)
repeat0 – 0 (always)
Supporting custom function :-
Comparing(text;searched;textPos;count1)
text – the text to be formatted.
searched – the text which is to be searche for its number of occurances.
textPos – Position (number) of searched text from the original text.
count1 – 1 (always)
PatternCountExact(text;searched;count1;repeat0)
———————————————————————————
Let (
[
text1 = text;
letter = Middle ( text1 ; count1 ; 1 );
repeat0 = If ( letter = Left ( searched ; 1 ) and Comparing(text1;searched;count1;1) = Length ( searched ) and Exact ( searched ; Middle ( text1 ; count1 ; Length(searched) ) ) ;
repeat0 + 1 ;repeat0 );
count1 = If ( letter = Left ( searched ; 1 ) and Comparing(text1;searched;count1;1) = Length ( searched ) and Exact ( searched ; Middle ( text1 ; count1 ; Length(searched) )) ;
count1 + Length ( searched ) ;count1+1 )
];
If ( count1 > Length ( text1 ) ; repeat0 ; PatternCountExact(text1;searched;count1;repeat0) )
)
———————————————————————————
Comparing(text;searched;textPos;count1)
———————————————————————————
Let (
[ text1 = text ;
value = searched;
letter = Middle ( text1; textPos ; 1 );
searchedLetter = Middle ( searched; count1 ; 1 )
];
Case (
count1 > Length ( value ) ; count1 -1 ;
letter = searchedLetter ; Comparing(text1;value;textPos+1;count1+1);
count1 – 1
)
)
———————————————————————————
