Remove part of name from left and right

5 ビュー (過去 30 日間)
Mekala balaji
Mekala balaji 2016 年 1 月 23 日
コメント済み: Walter Roberson 2016 年 1 月 23 日
I have the following table, and I want delete whatever it may be p to first "."(dot) or first "_"(underline), and also remove "_slot" (like _slot1, or _slot2, or etc).
A pr.vb023K
B pr.vb013K
C pr.vb010K
D Tv_pr12k_mm_ty004.vg_slot5
E Tv_pr.vf22k_ff01_hy004_slot1
My final output should be as belo:
A vb023K
B vb013K
C vb010K
D pr12k_mm_ty004.vg
E vf22k_ff01_hy004
Many many Thanks in advance.

採用された回答

Walter Roberson
Walter Roberson 2016 年 1 月 23 日
You question is almost exactly identical to someone else's at nearly the same time. See my answer there
  2 件のコメント
Mekala balaji
Mekala balaji 2016 年 1 月 23 日
Sir, I saw that answer, but if it is not sure what to remove, but only sure to remove about up to first "dot" or first "underline", then is there any other way?? Sincerely,
Walter Roberson
Walter Roberson 2016 年 1 月 23 日
new_cell_string = regexprep(old_cell_string, {'^[^._]+[._]', '_slot.*'}, {'', ''});
Note that this is not the same as your earlier requirement. For Tv_pr.vf22k_ff01_hy004_slot1 you wanted to remove both the Tv_ and the pr. not just up to the first dot or _
The previous code was fine for removing both.
Is the question going to be about removing all leading occurrences of (two alphabetic characters followed by a dot or underline) ? If so then
new_cell_string = regexprep(old_cell_string, {'^([A-Za-z][A-Za-z][._])+', '_slot.*'}, {'', ''});

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by