Problem with regexp Japanese

1 回表示 (過去 30 日間)
galaxy
galaxy 2020 年 3 月 12 日
コメント済み: galaxy 2020 年 3 月 12 日
Dear all,
I want to find the file paths in the large string by regexp such as:
As you see, pattern search was good in https://www.regextester.com/ . but in Matlab, Japanese string could not get as following:
>>str = ['a:\fawe\abc\AddNew_.doc '...
'C:\Users\Desktop\AddNew\_Copy_新しいフォルダーof_a.txt'];
>>pattern = '(?:[\w]\:|\\)(\\[a-zA-Z_\-\s0-9\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\uFF00-\uFFEF\u4E00-\u9FAF\u2605-\u2606\u2190-\u2195\u203B\.]+)+\.(txt|mat|pdf|doc|docx|xls|xlsx|cgt|slx|m)';
>>match_str = regexp(str, pattern, 'match')
match_str =
1×1 cell array
{'a:\fawe\abc\AddNew_.doc'}
Do you have any idea for resolve.
Thank you so much

採用された回答

Stephen23
Stephen23 2020 年 3 月 12 日
編集済み: Stephen23 2020 年 3 月 12 日
The \u syntax is not valid in MATLAB:
\u3000 % !!! NOT CORRECT !!!
To create a character from hexadecimal use \x:
\x3000
So you will need to change all of your \u... into \x....
  1 件のコメント
galaxy
galaxy 2020 年 3 月 12 日
I see.
Thank you for your support

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by