Or same thing for each value : #Include <Array.au3> Local $txt = "3" &@crlf& "1" &@crlf& "2" &@crlf& "3 " &@crlf& "4" &@crlf& "41" &@crlf& "42" &@crlf& "3" &@crlf& "5" &@crlf& "6" &@crlf& "42" Local $uniq = StringRegExp($txt, "(?s)\b(\d+)\b(?!.*\b\1\b)", 3) Local $aResult[UBound($uniq)][2] For $i = 0 To UBound($uniq) - 1 StringRegExpReplace($txt, "\b" & $