wordfind

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

finds words in a string (charchain)



See Also:

Example Illustration

 missing image of wordfind(txt,word,sep)

Syntax

[pp,ccc]=wordfind(txt,word,[sep])

Input Parameter

txt: charchain to search in
word: word to look for
sep: separators; default is {',',' ',';'}

Output Parameter

pp: array of hits
ccc: separated words

Examples


wordfind ('Introduced first in SolidGeometry 5.4', 'intro') % Not found
wordfind ('Introduced first in SolidGeometry 5.4', 'in') % 3rd word
wordfind ('Introduced first in SolidGeometry 5.4 in text', 'in') % two words




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 find specific words within a given string and return their positions and the separated words. It is part of the SolidGeometry library.

Input Parameters

Output Results

Algorithm Steps

  1. Initialize the default separators as a set containing a comma, space, and semicolon: sep={',',' ',';'}.
  2. Use the function getfuncparams to check if a custom separator is provided in varargin. If provided, update sep with the custom separators.
  3. Split the input string txt into words using the split function with the specified separators sep. Transpose the result to get a column vector of words: ccc=split(txt,sep)'.
  4. Find the positions of the specified word within the array of separated words ccc using the ismember function. Store the positions in the array pp: pp= find(ismember(ccc,word)).

Example Usage

Algorithm explaination created using ChatGPT on 2025-08-18 23:35. (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