Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageHardik 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.
Post Follow-up to this message"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
Post Follow-up to this messageHardik 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
Post Follow-up to this messageHi,
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
Post Follow-up to this messageHardik 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-
Post Follow-up to this message> 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.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.