char2strarr

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Artificial Intelligence
Introduced first in SolidGeometry 5.4, Creation date: 2023-12-13, Last change: 2025-09-15

converts a list of string inside a char chain into a string array

Description

RESULT IS LIKE: ["space on a" "a on table" "space on b" "b on table"]

See Also: strarr2char

Example Illustration

 missing image of char2strarr(chr,splt)

Syntax

strarr=char2strarr(chr,[splt])

Input Parameter

chr: char chain with quation mark separated strings
splt: splitchar default is '"'

Output Parameter

strarr: string array

Examples


x= '"START" "move a from b to table" "move b from c to a" "move c from table to b" "FINISH"'
y=char2strarr(x)
u=strarr2char(y)
x='space on $A, space on $B, $A on $B'
char2strarr(x,',')




Copyright 2023-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This function, char2strarr, is designed to convert a character chain containing strings separated by a specified delimiter into a string array. It is part of the SolidGeometry library, version 5.4, and was introduced by Tim Lueth in December 2023.

Input Parameters

Output

Algorithm Steps

  1. The function begins by determining the delimiter using the getfuncparams function. If no delimiter is provided, it defaults to a quotation mark ('"').
  2. The split function is used to divide the input character chain chr into parts based on the specified delimiter splt.
  3. The strtrim function is applied to remove any leading or trailing whitespace from each of the split strings.
  4. Empty strings are removed from the array using strarr(~ismember(strarr,'')).
  5. The resulting array is converted into a string array and transposed to ensure it is in the correct format.

Example Usage

Consider the following example:

x = '"START" "move a from b to table" "move b from c to a" "move c from table to b" "FINISH"';
y = char2strarr(x);

This will convert the character chain x into a string array y with each quoted segment as an element.

Another example with a different delimiter:

x = 'space on $A, space on $B, $A on $B';
char2strarr(x, ',');

Here, the delimiter is a comma, and the function will split the string accordingly.

Algorithm explaination created using ChatGPT on 2025-08-18 23:47. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21