How do i use regular expressions effectively for parsing my text?
이전 댓글 표시
Hello,
I am currently using regular expressions for parsing my text. The pattern is:
pattern = 'red(dy|dish)?'
regexp(text,pattern,'match')
the answer is reddy, reddish, red. However the pattern recognizes red in words like predominantly , predetermined etc. I do not want this to happen. I want the regular expressions to only return words which describe color red (example red, reddy, reddish). How do i change my pattern or regular expression accordingly? Any help in this regard would be highly appreciated.
Thanks, Phani
채택된 답변
추가 답변 (3개)
Azzi Abdelmalek
2013년 6월 19일
편집: Azzi Abdelmalek
2013년 6월 19일
text='red redy predominant red ade redish red vrd redishh'
pattern='(?<=\s)red(y|ish)?(?!\S)'
regexp([' ' text],pattern,'match')
Phanichin
2013년 6월 20일
0 개 추천
댓글 수: 2
Azzi Abdelmalek
2013년 6월 20일
They are different solutions and giving different results
Phanichin
2013년 6월 24일
카테고리
도움말 센터 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!