Chip,
I think you split the two strings into arrays.
You create two more arrays: $aMatches,  and $aNumWords (unless by 'length'
you mean number of characters)

The you look through the shorter array:

For($i;1;size of array(<shorter array>)

$pos1:=Find in array(<longer array>;$<shorter array>{$i})

if($pos1>-1) // this word matches

$thisMatch:=<shorter array>{$i} // a string of matches

$n_words:=1

// now you need to loop through the remaining words in <shorter array>
until you stop matching

$j:=$i+1 //        the word in <shorter array> to check next

$k:=$pos1+1 // the word in <longer array> that must match <shorter array>

while (<longer array>{$k} = <shorter array>{$j}) & ( $j< size of
array(<shorter array>))

$thisMatch:=$thisMatch+" "+<shorter array>{$j}

$n_words:=$n_words+1

end while


end if

End for


On Thu, Aug 22, 2019 at 1:13 PM Chip Scheide via 4D_Tech <
[email protected]> wrote:

> Given 2 strings,
> I want to find, and return, the longest substring which is the same in
> both, regardless where in either string the longest substring starts.
>
> ex:
> 1- This is my dog
> 2- My dog does not have fleas
> longest common string is 'my dog'
>
> how to go about this, efficiently?
> I am assuming that there is regex black magic that would do this.
>
> ---------------
> Gas is for washing parts
> Alcohol is for drinkin'
> Nitromethane is for racing
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[email protected]
> **********************************************************************



-- 
Kirk Brooks
San Francisco, CA
=======================

What can be said, can be said clearly,
and what you can’t say, you should shut up about

*Wittgenstein and the Computer *
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to