[–] HoneyTrap1488 0 points 3 points (+3|-0) ago 

Using regex for a simple pattern you know at compile-time is a lousy way to do it. Checking if a char is an ASCII letter can be done in 3 instructions in C: https://godbolt.org/z/HMvLLC . Using regex would be hundreds.

[–] psimonster 0 points 1 point (+1|-0) ago 

Instead of running a match inside a loop create a new string by regex replacing letters with nothing, then run the operation on each character in the new string.

[–] folgeyharry ago 

put a * after [a-zA-Z], otherwise you're only going to match 1 character strings

[–] argosciv [S] ago 

They are indeed only 1 character strings. Original string was converted to a CharArray, to then be iterated through.

[–] folgeyharry 0 points 1 point (+1|-0) ago  (edited ago)

I tried all 3 examples using mono on linux and they all worked fine. Also, why use regex at all? You can just compare x to 'a', etc. I included a 4th example in the pastebin which shows the complete program I tried.


[–] neogag ago  (edited ago)

I don't have time to look into this now, but know that there is a /i regex flag that means case-insensitive, which might be what you want.

edit: Also use this to iterate very quickly and find out what works/doesn't work: https://regex101.com/

[–] argosciv [S] ago  (edited ago)

Tried (?-i) in example A. Is /i proper syntax?

EDIT: Note that the programming language is C#.

[–] lemon11 0 points 1 point (+1|-0) ago 

I don't know C#, but if its engine is PCRE, the syntax for flags inside the pattern should be like (?i)pattern or (?i:pattern).