Matlab's regexp
has an emptymatch
option that controls whether it will allow an entire regex expression to match an empty string. It is off ("noemptymatch
") by default. See help regexp
.
Vertica's matching the 0-length empty string at the beginning is normal behavior for most regex dialects that I know, including anything Perl-like.
To get the same behavior as Vertica, where it can match 0-length strings, pass the 'emptymatch'
option in your regexp
call. Also pass 'once'
to prevent it from matching the empty spaces between each and every character in your string.
[a,b,c,d] = regexp('JJJ123', '\d*', 'emptymatch', 'once')