フィルターのクリア

regex question

3 ビュー (過去 30 日間)
Amish Rughoonundon
Amish Rughoonundon 2011 年 5 月 25 日
[EDIT: 20110525 11:04 CDT - reformat - WDR]
Hi,
I have the following code
[matchedToken] = regexp(scopeLine,'Channel\s0\sdisplays
\s(.*)','tokens');
I would like the regular expression to match this:
Channel 0 displays
Channel 1 displays
Channel 2 displays
Channel 3 displays
What I want to do is use the variable headercount in a for loop to increment the channel number automatically
% Keeps count of how many header names was located
headerCount = 0;
for j=0:3
[matchedToken] = regexp(scopeLine,'Channel\sheaderCount\sdisplays
\s(.*)','tokens');
headerCount++;
end
I cannot figure out how to do this.
Thanks for any help,
Amish

採用された回答

Walter Roberson
Walter Roberson 2011 年 5 月 25 日
[matchedToken] = regexp(scopeLine,sprintf('Channel\\s%d\\sdisplays
\\s(.*)',headerCount),'tokens');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAdding custom doc についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by