How many time the string matches

Clash Royale CLAN TAG#URR8PPPHow many time the string matches
I have a pattern like this one here *b* and a string like this one "abcdb" witch is matches twice.
*b*
I want to calculate the number of time string matches, but I have no clue how to achieve this in C language since I'm just a beginner.
Is there any hints of how can make this function in c?
strstr
Yes, I know but I need way out with the asterisk, sorry that It didn't show up earlier, I 've modified my question.
– 카림 사부
5 mins ago
1 Answer
1
For a simple pattern like *b*, you can use strstr defined in <string.h>:
*b*
strstr
<string.h>
const char *p = "abcdb";
p = strstr(p, "b");
p
For more complex regular expressions, there is no standard function to match generic patterns. You can try a install a regex library or write your own engine, a non trivial task, so say the least.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
In plain simple standard C? You can't, since C doesn't have any regular expression functions. There are other ways to do it than regular expressions though. I suggest you read a little about the
strstrfunction.– Some programmer dude
8 mins ago