ENG 6 Lecture Notes - Lecture 17: Matlab, Metacharacter
Document Summary
Matching any character: use dot: identifies any single character, including white space, ex. str = the rain in spain falls mainly on the plain. "; Locate sequences of 5 consecutive characters that end in ain". Startindex = 4 13 24 39 regexp(str,"ain","match") Selected characters [c1c2c3: matches any character contained within brackets. [c1-c2: matches any character in the range of c1 through c2. Str = "the rain in spain falls mainly on the plain. >> [mat idx] = regexp(str, "[a z]\w*", "match", "start") Mat = "the" "spain" idx = 1 13. \s any white space character: str = "the rain in spain falls mainly on the plain, >>[mat ix1 ix2] = regexp(str, "\w*n\s", "match", "start", "end") mat = "rain " "in " "spain " ix1 = "on " find all words starting with lower case m or capital m and ending with y. Str = "my flowers may bloom in may";