#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?ism)((volume|part)|(^,)\s?(vol|pt)[^.]+?)"
Local $sString = "Should Match: " & @CRLF & _
" a) Any occurences of "Volume" OR "Part" (Case Insensitive);" & @CRLF & _
" b) Any occurence of "vol" or "pt" (CI) that does not have [[comma][space] before AND [period] after;" & @CRLF & _
"" & @CRLF & _
"My volume 1 " & @CRLF & _
"My name vol2." & @CRLF & _
"My, volume 1 " & @CRLF & _
", pt. vol2." & @CRLF & _
"" & @CRLF & _
", part." & @CRLF & _
", pt." & @CRLF & _
", pt " & @CRLF & _
", vol" & @CRLF & _
". pt." & @CRLF & _
"" & @CRLF & _
"// Should match below as there is no [period] after it" & @CRLF & _
"The Red Pill, Pt 2" & @CRLF & _
", Pt 2"
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