#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^.*?([0-9]+-[a-zA-Z]{2,}-[0-9]+).*"
Local $sString = ""NE-390-SM-04"" & @CRLF & _
" --> "390-SM-04"" & @CRLF & _
"" & @CRLF & _
""90055-SL-01-J"" & @CRLF & _
" --> "90055-SL-01"" & @CRLF & _
"" & @CRLF & _
""NE-1478-SL-02"" & @CRLF & _
" --> "1478-SL-02"" & @CRLF & _
"" & @CRLF & _
""87007-QM-01-J"" & @CRLF & _
" --> "87007-QM-01"" & @CRLF & _
"" & @CRLF & _
""NE-9315-BM-01-A"" & @CRLF & _
" --> "9315-BM-01"" & @CRLF & _
"" & @CRLF & _
""3121-SP-01"" & @CRLF & _
" --> "3121-SP-01"" & @CRLF & _
"" & @CRLF & _
""1639-YL-01"" & @CRLF & _
" --> "1639-YL-01"" & @CRLF & _
"" & @CRLF & _
""NE-9922-WM-01-J"" & @CRLF & _
" --> "9922-WM-01"" & @CRLF & _
"" & @CRLF & _
""ND-2498-YL-01"" & @CRLF & _
" --> "2498-YL-01"" & @CRLF & _
"" & @CRLF & _
""C-4008-PP-03-J"" & @CRLF & _
" --> "4008-PP-03"" & @CRLF & _
"" & @CRLF & _
""876-C-4008-PP-03-J-234"" & @CRLF & _
" --> "4008-PP-03""
Local $sSubst = "\1"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm