Numeric extract from char

2 ビュー (過去 30 日間)
Murugan C
Murugan C 2020 年 10 月 1 日
コメント済み: Murugan C 2020 年 10 月 4 日
Hello all, I need to extract numbers from char. For exp
("Acb2hea" == 10)
("Acb2hea1" >= 15)
("Acb2hea" <= 20)
I used regular expression but unble to get exact value which I want as below. I am getting like. 2 10 2 1 15 2 20
But Need output like 10 15 20

採用された回答

Stephen23
Stephen23 2020 年 10 月 1 日
編集済み: Stephen23 2020 年 10 月 1 日
>> regexp('("Acb2hea" == 10)','\<\d+\>','match')
ans =
'10'
>> regexp('("Acb2hea1" >= 15)','\<\d+\>','match')
ans =
'15'
>> regexp('("Acb2hea" <= 20)','\<\d+\>','match')
ans =
'20'
If required use str2double to convert to numeric.
  1 件のコメント
Murugan C
Murugan C 2020 年 10 月 4 日
Thanks 😊

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by