@Jörg-Winkel said in Find/Replace Regex?:
It does, however, do exactly what I need today, so thanks a lot for your help.
I thought I might follow up with some more information as I don’t think you realise how powerful/loose the use of the \D actually is. This post is also for others hoping to learn something.
\D means “not a digit” which sounds okay until you consider that it really means ANY character that isn’t a digit. So alpha’s are certainly part of that group as the OP wanted. However it also includes punctuation characters such as ;:"',.? and if you see my image, it will include line feed and/or carriage return characters. So ANY character except for the 10 digit ones.
7c8348e5-542c-4197-b295-b2999b988889-image.png
The example in the image is admittedly made up on purpose to highlight the power of the \D but it shows how a regular expression (regex) can select other strings in error if one isn’t aware of what it means. Also note that I included a 3 non-digit plus 7 digit string in the example. Again the regex selected the portion it was required to find, that of the 6 digits following the 3 non-digit string. So the 7th digit was excluded. This means upon editing the string we finish up with ;#AB234567;8. I would say that’s a definite error. If only 6 digit strings were to be selected, a test at the end of the find expression would look for 1 or more digits and based on the criteria, either exclude that string or include all of it.
I’d say this is a prime example of a loosely made expression very likely to have unwarranted side effects.
Those who do create regexes for others take this into account and is often what we spend more time on, the “edge cases”. Edge cases can be likened to programming where 20% of the code does the work and 80% of the code is error checking. The percentages do vary according to who you talk to but the sentiment still exists across the programming world.
Terry