Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

regexp in Matlab 7
Hi,
I have a command with regexp which runs perfect in Matlab 6.5 but
gives the following error in Matlab 7

Multiple strings and patterns given to regexp must have the same
quantity.

The command is
regexp({'1' '2' '3' '4'}',{'1' '2'})

Any ideas,
Hardik

Report this thread to moderator Post Follow-up to this message
Old Post
Hardik Virani
04-28-05 02:01 AM


Re: regexp in Matlab 7
Hardik Virani wrote:
>
>
> Hi,
> I have a command with regexp which runs perfect in Matlab 6.5
> but
> gives the following error in Matlab 7
>
> Multiple strings and patterns given to regexp must have the same
> quantity.
>
> The command is
> regexp({'1' '2' '3' '4'}',{'1' '2'})
>
> Any ideas,
> Hardik

Only the obvious: use a loop.

Report this thread to moderator Post Follow-up to this message
Old Post
Michael Robbins
04-28-05 02:01 AM


Re: regexp in Matlab 7
"Hardik Virani" <viranihardik@yahoo.co.in> wrote in news:ef04427.-1
@webx.raydaftYaTP:

> Hi,
>    I have a command with regexp which runs perfect in Matlab 6.5 but
> gives the following error in Matlab 7
>
> Multiple strings and patterns given to regexp must have the same
> quantity.
>
> The command is
> regexp({'1' '2' '3' '4'}',{'1' '2'})
>
> Any ideas,
> Hardik

can you fill up the short one with empties?

Scott

Report this thread to moderator Post Follow-up to this message
Old Post
Scott Seidman
04-28-05 02:01 AM


Re: regexp in Matlab 7
Hardik Virani wrote:
>
>
> Hi,
> I have a command with regexp which runs perfect in Matlab 6.5
> but
> gives the following error in Matlab 7
>
> Multiple strings and patterns given to regexp must have the same
> quantity.
>
> The command is
> regexp({'1' '2' '3' '4'}',{'1' '2'})
>
> Any ideas,
> Hardik

From help regexp:
When both STRING and EXPRESSION are cell arrays of strings, REGEXP
matches the elements of STRING and EXPRESSION sequentially. The
number of elements in STRING and EXPRESSION must be identical.

Just pad your second cell with emty strings:
regexp({'1' '2' '3' '4'}',{'1' '2' '' ''})

ans =

[1] [1] [] []

HTH

PB

Report this thread to moderator Post Follow-up to this message
Old Post
PB
04-28-05 02:01 AM


Re: regexp in Matlab 7
Hi,
When I run the command in Matlab 6.5
regexp({'1' '2' '3' '4'}',{'1' '2'})

I get the following output
ans =

[1] []
[] [1]
[] []
[] []

I need to get the same output in Matlab 7. and besides I was reading,
Matlab 7 does allow a cell of strings in the second argument. I dont
understand why its not giving the required output.

-Hardik

Hardik Virani wrote:
>
>
> Hi,
> I have a command with regexp which runs perfect in Matlab 6.5
> but
> gives the following error in Matlab 7
>
> Multiple strings and patterns given to regexp must have the same
> quantity.
>
> The command is
> regexp({'1' '2' '3' '4'}',{'1' '2'})
>
> Any ideas,
> Hardik

Report this thread to moderator Post Follow-up to this message
Old Post
Hardik Virani
04-28-05 02:01 AM


Re: regexp in Matlab 7
Hardik Virani wrote:
> Hi,
>    When I run the command in Matlab 6.5
> regexp({'1' '2' '3' '4'}',{'1' '2'})
>
>   I get the following output
> ans =
>
>     [1] []
>      [] [1]
>      [] []
>      [] []
>
> I need to get the same output in Matlab 7. and besides I was reading,
> Matlab 7 does allow a cell of strings in the second argument. I dont
> understand why its not giving the required output.
>
> -Hardik
>
> Hardik Virani wrote:
> 

The REGEXP function changed, which is why you see different behavior.
Compare the documentation for REGEXP from MATLAB 6.5 and 7.0.  If you
need code that returns the same output in both versions, use a loop, as
was suggested in an earlier post:

match = [];
for pat = {'1','2'}
match = [match regexp({'1' '2' '3' '4'}',pat)];
end


-SteveSimon-

Report this thread to moderator Post Follow-up to this message
Old Post
Steve Simon
04-28-05 02:01 AM


Re: regexp in Matlab 7
> The REGEXP function changed,

Yes, REGEXP, REGEXPI and REGEXPREP are quickly evolving. These
functions have become much better over the last few releases. I'm
really happy with how they have improved.

Report this thread to moderator Post Follow-up to this message
Old Post
Michael Robbins
04-28-05 02:01 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Matlab archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:35 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.