Number of occurences for a string pattern
Posted: Mon Feb 29, 2016 9:20 am
by makas12
Is there a function to count number of occurrences of a string pattern in string list? Before writing a function, I want to know if there is out-of-the-box functionality to compute number of occurrences of a string pattern in a string list? Thanks,
Re: Number of occurences for a string pattern
Posted: Mon Feb 29, 2016 9:33 am
by EViews Gareth
No.
Re: Number of occurences for a string pattern
Posted: Fri Mar 04, 2016 2:13 am
by mamo
Hi,
here is a (case-sensitive) workaround in one line.
Let %s1 denote the shorter string occuring zero or more times in the longer string %s2. The code
Code: Select all
(@strlen(%s2)-@strlen(@replace(%s2,%s1,"")))/@strlen(%s1)
Best, mamo