Home > Archive > Matlab > April 2005 > regexp in Matlab 7
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
regexp in Matlab 7
|
|
| Hardik Virani 2005-04-27, 9:01 pm |
| 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
| |
| Michael Robbins 2005-04-27, 9:01 pm |
| 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.
| |
| Scott Seidman 2005-04-27, 9:01 pm |
| "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
| |
|
| 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
| |
| Hardik Virani 2005-04-27, 9:01 pm |
| 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
| |
| Steve Simon 2005-04-27, 9:01 pm |
| Hardik Virani wrote:[color=darkred]
> 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-
| |
| Michael Robbins 2005-04-27, 9:01 pm |
| > 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.
|
|
|
|
|