From: Delta V on 11 Jun 2010 16:06 I have to process files where I read line number 20, check for a pattern of string I'm looking for exists or not. I'm using textscan to read specific line number. This simple task is complicated when there are unknown number of spaces in between the pattern and no telling how many characters before or after the pattern. Thanks for looking in advance In the following example I'm looking for a match of 'NIKE RUNN M'. Any suggestions how to compare? example: file = fopen(fid_read); searchline = textscan(file,'%s',1,'delimiter','\n','headerlines',19); fclose(file); searchline{:} searchline = 'RIVER 069 NIKE RUNN M UPC28 '
From: Delta V on 11 Jun 2010 16:22 when read into matlab there are 10-15 extra spaces between RUNN and M (pulled off by this message board). these spaces fail the match if I use strmatch and other similar functions.
From: Jan Simon on 11 Jun 2010 16:41 Dear Delta, I do no exactly understand your problem. Do you want to replace repeated spaces by a single space? Str = regexprep(Str, '\s*', ' ') Or: Index = isspace(Str); Str(Index) = char(0); Str(findstr(Index, [0, 1]) + 1) = ' '; Str = Str(find(Str)); Good luck, Jan
|
Pages: 1 Prev: evaluating a character as a variable? Next: mdce server not reachable |