Got Questions? Get Answers.
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:
regexp for any character sequence ( numeric or non numeric)

Subject: regexp for any character sequence ( numeric or non numeric)

From: Gregthom

Date: 29 Sep, 2009 21:59:09

Message: 1 of 2

Greetings I have a lines simillar to these in my text file

log-entry: 8954756>test case John Dr.,Pine Hooks Drive0t646pln,Left-
Wheel (rear)
log-entry: 054756>new case Peter PhD,Abe Falls LN23pl646pln,Right-
Wheel (rear)
...


Now I need to scan the file for lines containing

'log-entry:' * 'Right-Wheel (rear)'
and
'log-entry:' * 'Left-Wheel (rear)'

In the above lines, * denotes anything. I am only interested in the
lines where both log-entry and 'Left-Wheel (rear)' appear. I was
thinking of doing this using regexp in matlab but it is not working as
I expect.

I have tried things like these:

[lm index ] = regexp(textbuffer,'log-entry: \w* Right-Wheel
(rear)','match','start')

Can anyone suggest some things I might try ?

Thank you

Subject: regexp for any character sequence ( numeric or non numeric)

From: per isakson

Date: 29 Sep, 2009 22:39:02

Message: 2 of 2

gregthom <gregthom99@yahoo.com> wrote in message <a883d102-e07f-458f-96df-22095d50cf60@k33g2000yqa.googlegroups.com>...
> Greetings I have a lines simillar to these in my text file
>
> log-entry: 8954756>test case John Dr.,Pine Hooks Drive0t646pln,Left-
> Wheel (rear)
> log-entry: 054756>new case Peter PhD,Abe Falls LN23pl646pln,Right-
> Wheel (rear)
> ...
>
>
> Now I need to scan the file for lines containing
>
> 'log-entry:' * 'Right-Wheel (rear)'
> and
> 'log-entry:' * 'Left-Wheel (rear)'
>
> In the above lines, * denotes anything. I am only interested in the
> lines where both log-entry and 'Left-Wheel (rear)' appear. I was
> thinking of doing this using regexp in matlab but it is not working as
> I expect.
>
> I have tried things like these:
>
> [lm index ] = regexp(textbuffer,'log-entry: \w* Right-Wheel
> (rear)','match','start')
>
> Can anyone suggest some things I might try ?
>
> Thank you
>
>
Try replace "\w*" by ".+" meaning - any character - one or more.
Not all characters you want to match with "\w*" are "word characters".

/per

Tags for 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