# How to use the function regexp?

1 view (last 30 days)
Monica S on 11 May 2021
Commented: Monica S on 14 May 2021
I am working out problems from Cody and I have seen many top solutions are solved using 'regexp' funciton. Can anyone please explain me the functionality of regexp?
I have already read the matlab documents of this fucntion but still I am unable to understand certain things. For example, in problem 838 of 'Check if number exists in vector' where we need to check that number 'a' is present in the vector. Hence, if a = 2 and b = [1 2 3 4] and when use the command y = any( b(:) == a) it gives me logical output as 1. However, when I try the command regexp '' '(/@ y = any( b(:) == a))' it throws me an empty matrix as the result, why is this?
I don't get it where I am going wrong..?
Monica S on 14 May 2021
@Stephen Cobeldick & @Bob Thompson Thanks again for explaining the reg expression, @Rik: You took your valuable time to write about code and functionality of cody, thank you.
@Atsushi Ueno I didn't know this is dynamic regular expression, when I checked MatLab documentation I open the first link about regexp. Thanks, I learnt there is much more for me to check out.
P.S
Of course, Cody is not the platform to learn MatLab, I am using it test my analytical and programming skills.