MATLAB Answers

How to use the function regexp?

조회 수: 4(최근 30일)
Monica S
Monica S 2021년 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