Implementing ellipsis, also known as dot dot dot or "..." for line continuation in a regular expression statement
Show older comments
So this is driving me nuts. Matlab documentation says "dot dot dot" or ellipsis is treated like a space, but obviously not and it's driving me crazy. I'm sure it's something so easy to figure-out for an experienced Matlab programmer, which clearly I'm not. I appreciate your help on this matter.
parts = regexp(filtered, '(?<TNT>d+\.(\d)+), (?<T>\w*), (?<refTm>\d+), (?<P>\w+), (?<tmSpyRefns>[^\w]\w+,(?<tmSpyRefmns>[^\w]\w+), ...
(?<rbncntrl>[^w]\w+), (?<cntrlStatus>\d+, (?<satsTrk>\d+), (?<lastRbUpdt>\d+)', 'names')
I've tried ending single quotes on first part and then wrapping second part expression with it's own quotes. I've tried placing the comma on second part. Combinations of comma inside quotes. Matlab says ellipsis is treated like a space so the above should technically work. Well it doesn't. I need help. Thank you for your time and on this piece of matlab code.
1 Comment
"Matlab documentation says "dot dot dot" or ellipsis is treated like a space..."
For character vectors the MATLAB documentation actually states "Build a long character vector by concatenating shorter vectors together... The start and end quotation marks for a character vector must appear on the same line" and procedes to give examples.
Your code does not follow what the MATLAB documentation specifies.
Accepted Answer
More Answers (2)
When you use ellipses inside a character array, you have to end it on that line, start it again on the next line, and concatenate the different parts. In this case, that might look like this (check that the pattern in regexp is accurate):
parts = regexp(filtered, ['(?<TNT>d+\.(\d)+), (?<T>\w*), (?<refTm>\d+), (?<P>\w+), (?<tmSpyRefns>[^\w]\w+,(?<tmSpyRefmns>[^\w]\w+), ' ... not sure if the space belongs inside the pattern or not
'(?<rbncntrl>[^w]\w+), (?<cntrlStatus>\d+, (?<satsTrk>\d+), (?<lastRbUpdt>\d+)'], 'names')
1 Comment
jimmy zubiate
on 5 Mar 2022
jimmy zubiate
on 2 Mar 2022
3 Comments
"I've tried the following too. No dice. Matlab doesn't like it."
Because you built two separate character vectors, without joining them together like the MATLAB documentation shows:
As Voss stated, you are missing the square brackets.
jimmy zubiate
on 5 Mar 2022
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!