way to check if a string contains only alphabet
I need a line of code to check if a string contains only alphabet characters or whitespaces, what is the best way to do so
4 Replies
arion
REPL Result: Success
Result: bool
Compile: 392.695ms | Execution: 53.353ms | React with ❌ to remove this embed.
If you want it more structured you can extract the predicate
arion
REPL Result: Success
Result: bool
Compile: 422.296ms | Execution: 55.121ms | React with ❌ to remove this embed.
Regarding what the best way to do so is, that well, it depends.
Is your interpretation of "best" speed? memory usage? how many lines of code?
Linq is nice on the lines of code but there are memory implications and it might not be the fastest.
You can try to write your own implementation to try to beat System.Linq's
.All