Thread Subject: %s vs. %c in textscan with multiple delimiters

Subject: %s vs. %c in textscan with multiple delimiters

From: Heywood

Date: 3 Feb, 2009 16:14:04

Message: 1 of 1

I've run into a problem with using textscan to parse lines with multiple null fields. For example:

>> line='a,b,c,d,e,f,g';
>> foo=textscan(line,'%s','delimiter',','); foo{:}'
ans =
    'a' 'b' 'c' 'd' 'e' 'f' 'g'

>> foo=textscan(line,'%c','delimiter',','); foo{:}'
ans =
abcdefg

... works as expected. However,

>> line='a,b,c,d,,,g';
>> foo = textscan(line,'%s','delimiter',','); foo{:}'
ans =
    'a' 'b' 'c' 'd' '' '' 'g'

>> foo = textscan(line,'%c','delimiter',','); foo{:}'
ans =
abcd,g

... so when scanning with %s, the "identify multiple consecutive delimiters" functionality works, but with %c it fails. Is this expected behaviour, or is this a bug?

Thanks in advance for any guidance.

/HJ

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
textscan sscanf Heywood 3 Feb, 2009 11:15:05
rssFeed for this Thread

Contact us at files@mathworks.com