I need to return a string that has the greatest coincidence. I tried to add groups to define the length by number of characters. But not working. #include <Array.au3>
$sText = _
'14D36E972-E325-11CE-BF91-08002BE10318' & @CRLF & _
'4D36Err2-E325-11CE-BFC1-08002BE10318' & @CRLF & _
'1D36E972-E325-11CE-BFC1-08452BE10318' & @CRLF & _
'4D36E972-E325-11CE-BFC1-08002BE10218' & @CRLF & _
'3D36E977-E325-11CE-BFC1-08002BE10318' & @CRLF & _
'4D36E9r6-E325-11CE-BFC1-08002BE10318' & @CRLF & _
'4D36Ee72-E325-11kE-BFC1-08002BE10318' & @CRLF & _
'4D36Ew2-E325-11CE-BFC1-08002BE10318'
$sPat = '4D36E972-E325-11CE-BFC1-08002BE10318'
; $sPat = '4'
_GetMaxSimilar($sText, $sPat)
Func _GetMaxSimilar($sText, $sPat)
$aPat = StringSplit($sPat, '')
$Len = StringLen($sPat) -1
$aPat0 = '(?m)^('
For $i = $Len To 1 Step -1
$aPat0 &= 'Q' & StringLeft($sPat, $i) & 'E.*|'
; $aPat0 &= '(Q' & StringLeft($sText, $i) & 'E)(.*)|'
Next
$aPat0 = StringTrimRight($aPat0, 1) & ')'
MsgBox(0, 'Pattern', $aPat0)
$Out = StringRegExp($sText, $aPat0, 3)
; MsgBox(0, 'UBound', UBound($Out))
_ArrayDisplay($Out, 'Array')
EndFunc