In MATLAB, ...
is used to continue a line to the next line. But if I want to continue a long string within quotation, what can I do? ...
will be treated as a part of the string itself.
Using []
is not a perfect solution since in most cases I use sprintf/fprintf
to parse a long string like sql query. Using []
would be cumbersome. thanks.
If a statement does not fit on one line, enter three periods ( ... ) , also called dots, stops, or an ellipsis, at the end of the line to indicate it continues on the next line. Then press Enter or Return. Continue typing the statement on the next line.
c = newline creates a newline character. newline is equivalent to char(10) or sprintf('\n') . Use newline to concatenate a newline character onto a character vector or a string, or to split text on newline characters.
Description. newStr = splitlines( str ) splits str at newline characters and returns the result as the output array newStr . splitlines splits at actual newline characters, not at the literal \n . To split a string that contains \n , first use compose and then use splitlines .
newStr = split( str , delimiter ) divides each element of str at the delimiters specified by delimiter . The output newStr does not include the delimiters. newStr = split( str , delimiter , dim ) divides each element of str into a vector oriented along the dimension specified by dim .
If you put the string in brackets, you can build it in several pieces:
s = ['abc' 'def' ...
'ghi'];
You can then split that statement into several lines between the strings.
answer=['You can divide strings '...
,'by adding a comma '...
,'(as you probably know one year later).'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With