Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Manipulation of strings in cellarray

Subject: Manipulation of strings in cellarray

From: Robin Jens

Date: 14 Mar, 2011 21:02:07

Message: 1 of 2


Hi

What if I have a cellarray containing some strings:

Example:

cellarray={'Test-Bar.bh-bell-1mm' 'Best-Bak.hh-belldd-2mm'}

Every string has one thing in commen. All strings contain tre spaces '-'. I want to delete all from each strings after the second '-'. This means I should get:

cellarray={'Test-Bar.bh' 'Best-Bak.hh'}

I know I can use regexp to manipulate the strings, but I am not very good at it.

Best Regards

Robin Jens

Subject: Manipulation of strings in cellarray

From: Jeremy

Date: 14 Mar, 2011 21:56:06

Message: 2 of 2

Hi Robin,

I would do something like this:

for i = 1:size(cellarray,2)
 temp = strfind(cellarray{i},'-');
 cellarray{i} = cellarray{i}(1:temp(2)-1);
end

Seems like that should take care of it.
Jeremy

Tags for this Thread

No tags are associated with this thread.

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.

Contact us