-1

「。」で始まるファイル内のすべての文字列を見つけようとしています。MATLAB で。私は次のコードを持っています、

data_files = 's.txt';
 C = textread(data_files, '%s', 'delimiter', '\n');
filetext = fileread(data_files);
expr='\.' ;
fileread_info = regexp(filetext, expr, 'match');
fid = fopen('size.txt', 'wt');
fprintf(fid, '%s\n',fileread_info{:});

入力:

.hello world
hello there
.can i help you
no

出力は次のとおりです。

.
.

それ以外の

.hello world
.can i help you

「。」で始まる文字列全体を抽出するにはどうすればよいですか。「。」と書くだけではなく、ファイルに?

4

1 に答える 1

2

次のように正規表現を変更してみてください

expr = '^\s*\..*$' ;

.*で始まる行のすべての内容に一致する必要があります.

于 2013-11-08T19:40:30.740 に答える