How to use the function regexp?

2 次查看(过去 30 天)
Monica S
Monica S2021-5-11
评论: Monica S ,2021-5-14
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..?
Thanks in advance!
  5 个评论
Monica S
Monica S 2021-5-14
@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.

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by