- ^ is the start of the string, not of the searched pattern.
- Equivalently $ is the end of the string, not the pattern, too.
Find the string into an special bracket
7 次查看(过去 30 天)
显示 更早的评论
Hello All, I have a string.
Ex: str = 'abc = "xyz";'
I want to use regexp command to find out "xyz" in below string.
my patern :
pat = '^=.;$'
with meaning (as my understanding)
_^= : beginning with =
. : get all thing between
;$ : ending with ;_
and run with
tk = regexp(str, pat) --> tk = [] in result
what wrong with my commands?
Thanks!
0 个评论
采纳的回答
Jan
2018-7-21
编辑:Jan
2018-7-21
What about:
regexp(str, '"(.*?)"', 'match')
or
regexp(str, '"([^"]*)"', 'match')
2 个评论
Jan
2018-7-23
[MOVED from section for answers] Tan Phan wrote:
Thank for your answer.
I have more question.
What happen if str is not a string I input from command Window.
I save it in file and using fopen/textscan to parse it.
In that file with information : abc = 'xyz';
I changed "xyz" to 'xyz' and I can not parse it with your regexp command ( ' '(.*?)' ' or ' '([^']*)' ') is not available in Matlab with my test.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!