Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定以下示例:
str = 'deriv*dot(N,iv)'; expr = 'iv'; idx = regexp(str,expr);
这将返回带有 4 和 13 的 idx。如何只找到不属于单词的“iv”?
我尝试在 expr 中使用 Lookaround Operators,但无法得到我想要的结果。谢谢您的帮助。
似乎 Matlab 有它自己的单词边界转义序列。
expr = '\<iv\>';
这将单词定义为由字母、数字和下划线组成的任何内容。如果您想要自己的定义(即只有字母),那么您需要环顾四周:
expr = '(?<![a-zA-Z])expr(?![a-zA-Z])';