Compare strings which contains the same pattern by ignoring case sensitivity and some expressions like underscores

19 ビュー (過去 30 日間)
Hi,
I have 2 cell array which consist of different strings. I want to find the corresponding strings which contains the same pattern but meanwhile I want to ignore case sensitivity and some expressions like underscores, spaces and hyphen.
Normally with:
exp = '[^ \f\n\r\t\v.,_-]*';
regexpi(CellArray1{i,:},CellArray2,'match');
does the job partly but it compares the strings for whole and if it contains, it does not correspond.
Is there any way to compare strings which contains the same pattern by ignoring the case sensitivity and some expressions?

採用された回答

埃博拉酱
埃博拉酱 2022 年 7 月 7 日
You might remove those expressions to be ignored and unify the strings all to lowercase before doing actual comarison.
  1 件のコメント
Ahmet Hakan UYANIK
Ahmet Hakan UYANIK 2022 年 7 月 7 日
Then seems like there are no function which does that job in a single line of command.
Thank you for the suggestion. I have proceeded as you proposed.

サインインしてコメントする。

その他の回答 (1 件)

Abderrahim. B
Abderrahim. B 2022 年 7 月 7 日
編集済み: Abderrahim. B 2022 年 7 月 7 日
Unify strings first using eiither upper or lower.
% learn about the functions
doc upper
doc lower
% Examples
upper("abcd")
ans = "ABCD"
lower(ans)
ans = "abcd"

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by