フィルターのクリア

Extracting numbers from string

3 ビュー (過去 30 日間)
James Ang
James Ang 2016 年 4 月 4 日
コメント済み: James Ang 2016 年 4 月 5 日
Hi,
I've some example strings:
CS-TZ24SKEW --> 24
CU-V18RKH-1 --> 18
CS-S24RKH-1 --> 24
CS-XC9RKD-3 --> 9
RS-PS9QK --> 9
CU-V18RWA --> 18
CS-KC18QKH-8 --> 18
CU-QA18RKH-8 --> 18
All I want to do is to extract the numeric values as shown on the right side of the respective strings. Is this possible with a couple of lines of code?
Thanks in advance.

採用された回答

Walter Roberson
Walter Roberson 2016 年 4 月 4 日
S = {'CS-TZ24SKEW', 'CU-V18RKH-1'};
extracted = regexprep(S, '^(\D+)(\d+)(.*)', '$2');
  1 件のコメント
James Ang
James Ang 2016 年 4 月 5 日
Thank you Walter!

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

その他の回答 (1 件)

Kuifeng
Kuifeng 2016 年 4 月 4 日

カテゴリ

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