[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #38149] regexp: doesn't return empty tokens --
From: |
Nicholas Jankowski |
Subject: |
[Octave-bug-tracker] [bug #38149] regexp: doesn't return empty tokens -- they just disappear |
Date: |
Fri, 22 Jul 2022 16:57:52 -0400 (EDT) |
Update of bug #38149 (project octave):
Priority: 5 - Normal => 3 - Low
_______________________________________________________
Follow-up Comment #17:
this appears to still be an issue in curred dev branch for v8.0.0
in the comment #0 code, the 'this works' example matches between octave v8.0.0
and matlab 2022a. The second two work in matlab but in Octave produce:
error: t(2): out of bound 1 (dimensions are 1x1)
for Rik's test script in comment #13, matlab 2022a currently produces:
>> te = regexp ('abc', 'abc(z?)', 'tokenExtents');
celldisp (te)
te{1} =
4 3
>> te = regexp ('abce', '((a)(z)?b(c)(z*))(z)?(e)?', 'tokenExtents');
celldisp (te)
te{1} =
1 3
4 3
4 4
>> [T, TE, NM] = regexp (sprintf('%s','John Davis\nRogers, James'),
'(?<first>\w+)\s+(?<last>\w+)|(?<last>\w+),\s+(?<first>\w+)', 'tokens',
'tokenExtents', 'names');
>> celldisp (T)
T{1}{1} =
John
T{1}{2} =
Davis
T{2}{1} =
nRogers
T{2}{2} =
James
>> celldisp (TE)
TE{1} =
1 4
6 10
TE{2} =
12 18
21 25
>> NM(1).first
ans =
'John'
>> NM(1).last
ans =
'Davis'
>> NM(2).first
ans =
'James'
>> NM(2).last
ans =
'nRogers'
while octave produces:
>> te = regexp ('abc', 'abc(z?)', 'tokenExtents');
>> celldisp (te)
te{1} =
4 3
>> te = regexp ('abce', '((a)(z)?b(c)(z*))(z)?(e)?', 'tokenExtents')
;
>> celldisp (te)
te{1} =
1 3
1 1
3 3
4 3
4 4
>> [T, TE, NM] = regexp (sprintf('%s','John Davis\nRogers, James'),
'(?<first>\w+)\s+(?<last>\w+)|(?<last>\w+),\s+(?<first>\w+)', 'token
s', 'tokenExtents', 'names');
>> celldisp (T)
T{1}{1} =
John
T{1}{2} =
Davis
T{2}{1} =
nRogers
T{2}{2} =
James
>> celldisp (TE)
TE{1} =
1 4
6 10
TE{2} =
12 18
21 25
>> NM(1).first
ans = John
>> NM(1).last
ans = Davis
>> NM(2).first
ans = James
>> NM(2).last
ans = nRogers
where the only difference appears in the 2nd "celldisp (te)" line.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?38149>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Octave-bug-tracker] [bug #38149] regexp: doesn't return empty tokens -- they just disappear,
Nicholas Jankowski <=