Comment on: I suck at regex... Can someone please explain why only example C is working here?
0 10 Aug 2019 10:21 u/berne in v/programmingComment on: I suck at regex... Can someone please explain why only example C is working here?
So? What where you actually trying to do, and how did you solve it? :-)
Comment on: For 40 years, computer scientists looked for a solution that doesnt exist
Finally! However, there are a couple of interesting approximating solutions, for instance: Polylogarithmic Approximation for Edit Distance and the Asymmetric Query Complexity
Okay. I was just curious - because it looked so overly elaborate just for detecting letters. I figured you had a reason besides the utilitarian to use regexes and that the input char array was beyond your control or for "performance considerations".
There is an IsLetter(...) method in the Char class that can detect if a character is a Unicode 'letter' but that includes non-english letters. The simplest (a fastest) way to detect if a char is an english letter would be simply "if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) ...". This will not have any of the overhead that string conversions and regexes have and will also use the processor's cache and speculative execution efficiently - if that is ever a consideration.
Using regexes can be very efficient but mostly for complex syntaxes or longer 'strings'. Rolling your 'own' parser in such a case is likely a waste of time.
Good luck!