I have avoided regexpressions till now, but now I have to do some matching than usual, and quickly hacking up pascal string code won't be faster I fear.
I got somewhat on track, but then got stuck
My first problem is matching strings like
; this is a title of article part 1
; this is a title of article part 10
; this is a title of article part, #10
where the "this is a title" is variable. But it should end in a part clause, and the variable part isn't allowed to e.g. contain ;
I want to replace them by ($0) minus the ;, but I stringreplace that away for now.
what i got is
s2:=ReplaceRegExpr(';[^;()\?]+\spart[,]*\s[#]*[\d]+',s,'_($0)');
but it fails to match multiple numbers at the end (the "part 10" string), and the one with a comma after part.
Any improvements, simplifications, comments? The expression is probably more complicated due to me experimenting.
p.s. ReplaceRegeexpr is from one of the Sorokin regexpr example programs, it just creates the class, assign the first argument to .expression and does a .replace with the second and third arguments.
p.s.2 entering the expression in some online tools does seem to match the multi digit numbers (part 10). Maybe some syntax difference?