MATLAB Answers


Regular expressions, builing up a simple expression for a search

Adriel Perez Tellez さんによって質問されました 2019 年 7 月 18 日
最新アクティビティ Adriel Perez Tellez さんによって コメントされました 2019 年 7 月 18 日
Hello All,
I am stuck with a regular expression and I would appreciate your help. I want to list some specific cases from some simulations. For instance, I have the following case names:
Until now I just needed to do something simple, like getting the cases that started with sw, or wk, or st:
However, now I want to find of those cases, the ones that also contain 400_0 and 420_0
I undertand the $ character can be used to give me the end, and it could work with something like this, right?
The complete expression would be something like this below. However, I tried several different variations without success. For instance using [a-z_]+. etc.
'^(sw|wk|st) 'something here?' $(400_0.inf|420_0.inf)'
Thanks in advance!
Best regards,
Adriel Perez

  0 件のコメント

サインイン to comment.




1 件の回答

Adam Danz
回答者: Adam Danz
2019 年 7 月 18 日
編集済み: Adam Danz
2019 年 7 月 18 日

I recommend that site when building regular expressions.
% ^ start ^^ ^ ^ ^
% ^^ ^ ^ ^ end
% ^^ anything in between
% ^ .........^ escape characters (\) for decimal points

  2 件のコメント

2019 年 7 月 18 日
Another way to write the end of that regular expression would be:
And the .+ could be .* depending on whether or not you want something between the two expressions.
Adriel Perez Tellez 2019 年 7 月 18 日
That worked great.

サインイン to comment.

Translated by