Syntax
[var,patt]=varsofstringpattern(cond)
Input Parameter
cond : | | string array with terms that use $XXX as variable name |
Output Parameter
var : | | string array with variable Name including %char |
patt : | | |
Examples
varsofstringpattern(["space on $A", "space on $C", "$A on $B"])
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 algorithm is designed to extract variable names from a string array where variables are denoted by a dollar sign ($) followed by a sequence of letters. The function is named varsofstringpattern
and is part of the SolidGeometry library.
Input Parameters
- cond: A string array containing terms with variables represented as $XXX, where XXX is a sequence of letters.
Output Results
- var: A string array containing the unique variable names extracted from the input, including the dollar sign.
- patt: A modified version of the input string array where the variable names are replaced with a placeholder.
Algorithm Steps
- Define the variable prefix as
ss="$"
.
- Create a search pattern
searchpat
that matches the dollar sign followed by a sequence of letters.
- Replace occurrences of the search pattern in
cond
with the dollar sign, storing the result in patt
.
- Initialize an empty array
var
to store extracted variables.
- Iterate over each element in
cond
:
- Extract variable names matching the search pattern from the current element.
- Convert the extracted names to a string and append them to
var
.
- Use
unique(var,'stable')
to remove duplicate variable names while preserving their order.
Example
Calling varsofstringpattern(["space on $A", "space on $C", "$A on $B"])
will return:
- var: ["$A", "$C", "$B"]
- patt: ["space on $", "space on $", "$ on $"]
Algorithm explaination created using ChatGPT on 2025-08-18 23:55. (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