I have input-cell = {'ABCD', 'ABD', 'BCD'}
. How can I put the operator <
into the strings in input-cell?
The expected output should be:
output-cell = {'A<B<C<D', 'A<B<D', 'B<C<D'}
To insert a fixed character (<
) between the characters of each string in a cell array: you can use regexeprep
as follows:
input_cell = {'ABCD', 'ABD', 'BCD'}; %// input cell array
c = '<'; %// character to be inserted
output_cell = regexprep(input_cell, '.(?=.)', ['$0' c]); %// output cell array
Result:
output_cell =
'A<B<C<D' 'A<B<D' 'B<C<D'
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