I have the following regex:
r'\d.\s(.*)\sשנה.*.docx'
That works for titles like 1. בראשית שנה א_ - הבדלה על קפה.docx
but is not working for 10. מקץ שנה א_ - פדיון שבויים.docx
Any help havre?
I have the following regex:
r'\d.\s(.*)\sשנה.*.docx'
That works for titles like 1. בראשית שנה א_ - הבדלה על קפה.docx
but is not working for 10. מקץ שנה א_ - פדיון שבויים.docx
Any help havre?
You are missing a digit in
10.because\d.\smatches a single digit, then a single any character except a newline and then a whitespace character.If you want to keep the capture group, you could make the dot star non greedy, escape the dots to match them literally and use word boundaries
\bto prevent partial word matches:Regex demo