#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?ui)(?|(e)(pisodes?)|(c)(hapters?)|(c)(hs?)|(e)(ps?)|(c)(s?)|(e)(s?)|()())\s*((\d+(?:\.\d+)?(?:[A-Z]\b)?)(?:\s*(?:[,&+-]|and)\s*(?:(?:e(?:pisodes?)|c(?:hapters?)|c(?:hs?)|e(?:ps?)|c(?:s?)|e(?:s?)|)\s*)?(?4))*)"
Local $sString = "chapter 2A Hello " & @CRLF & _
"chapter 2AHello" & @CRLF & _
"text chapter 25.6 text" & @CRLF & _
" // c~25.6" & @CRLF & _
"text chapters 23, 24, 25 text" & @CRLF & _
" // c~23-25" & @CRLF & _
"text chapter 23, 25 text" & @CRLF & _
" // c~23 & 25" & @CRLF & _
"text chapter 23 & 24 & 25 text" & @CRLF & _
" // c~23-25" & @CRLF & _
"text c25.5-30 text" & @CRLF & _
" // c~25.5-30" & @CRLF & _
"text c99-c102 text" & @CRLF & _
" // c~99-102" & @CRLF & _
"text chapter 1 - 3 text" & @CRLF & _
" // c~1-3" & @CRLF & _
"33 text chapter 1, 2 text 3" & @CRLF & _
" // c~1-2" & @CRLF & _
"chapter 25.6 & chapter 29" & @CRLF & _
" // c~25.6 & 29" & @CRLF & _
"chapter 25+c26" & @CRLF & _
" // c~25-26" & @CRLF & _
"chapter 25 + 26 + 27" & @CRLF & _
" // c~25-27" & @CRLF & _
"chapter 10.4C" & @CRLF & _
" = c~10.4 part 3" & @CRLF & _
"chapter 2B" & @CRLF & _
" = c~2 part 2"
Local $sSubst = ""
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