C#: How to list all possible capital/non-capital combinations of a name
Watch this threadPage 1 of 1
Skip to page:
Darya.
Badges:
17
Rep:
?
You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
In the above screenshot I've got an if statement where if the username is Darya, it welcomes me as an administrator, and if not, it welcomes me as a basic user. Unfortunately, I've only listed "Darya", "darya" and "DARYA" as the combinations that will welcome as an administrator. However, if the username is "dARyA" or any other combination of those 5 letters in that order but not with the specific capitalizations listed in the if statement, it will only say that I'm a basic user. Is there any way of saying if the username is *any* version of the letters d, a, r, y and a in that order, using any capitalization, it will say that I'm an administrator?
At the moment the only route I can think of is to manually write every possible form of Darya using all the possible capitalizations, however there are tens of combinations and I really don't think it's efficient to spend a lot of time doing that.
So does anyone have any way to recognize that any form of Darya is an administrator without listing all of them?
Thanks!!
Last edited by Darya.; 1 year ago
0
reply
Strange5050
Badges:
17
Rep:
?
You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#2
Report
#2
It would depend whether you need any variation to be unique. E.g if Dayra is different from DAyra etc.. If this doesn't matter you can simply force the input to lower case and check against that. E.g:
Of course, you could do this the opposite way and use 'ToUpper()' as well. This way you can simply check against 1 variation.
Relevant documentation:
https://docs.microsoft.com/en-us/dot...r?view=net-5.0
https://docs.microsoft.com/en-us/dot...r?view=net-5.0
Code:
username = username.ToLower(); // <-- This is an actual method you can use on strings if (username == "dayra") { // etc.. etc.. }
Relevant documentation:
https://docs.microsoft.com/en-us/dot...r?view=net-5.0
https://docs.microsoft.com/en-us/dot...r?view=net-5.0
Last edited by Strange5050; 1 year ago
1
reply
Darya.
Badges:
17
Rep:
?
You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#3
(Original post by Strange5050)
It would depend whether you need any variation to be unique. E.g if Dayra is different from DAyra etc.. If this doesn't matter you can simply force the input to lower case and check against that. E.g:
Of course, you could do this the opposite way and use 'ToUpper()' as well. This way you can simply check against 1 variation.
Relevant documentation:
https://docs.microsoft.com/en-us/dot...r?view=net-5.0
https://docs.microsoft.com/en-us/dot...r?view=net-5.0
It would depend whether you need any variation to be unique. E.g if Dayra is different from DAyra etc.. If this doesn't matter you can simply force the input to lower case and check against that. E.g:
Code:
username = username.ToLower(); // <-- This is an actual method you can use on strings if (username == "dayra") { // etc.. etc.. }
Relevant documentation:
https://docs.microsoft.com/en-us/dot...r?view=net-5.0
https://docs.microsoft.com/en-us/dot...r?view=net-5.0
1
reply
X
Page 1 of 1
Skip to page:
Quick Reply
Back
to top
to top