Here is an interesting one I'm currently working with & I'd like some advice on how to accomplish "the next step".
I am pulling names from a list of hi-score players on a gamer spot i run with a friend. These names look like the following examples: 1) LOUiS1gaMer1dawg444 2) Leet__Homie 3) M4-bmw4LIFE 4) KISSMYBUTT1111
Here is my current code, which extracts the name from the element, formats it to lowercase, then uses a series of stringbuilder variables to format it/remove bad words/change to PG-rated words/remove #s
The resulting strings look like this: 1) louisgamerdawg 2) elitehomie 3) mbmwlife 4) kissmybehind
Now that's great for me, saves time & looks a lot cleaner than it used to...for posting to the HIGH-SCORES board. I used to have to enter it manually, all 300 ppl's names (and think of a nickname for each).
But you see the name lousgamerdawg from the resulting formatting....It's still too long to fit into my high-score list. It needs to be 10 or less characters.
Ok so here is the help i need.....
1) How do I truncate that instance of builder aka (humanized) down to 10 chars..before i convert to string & add to my high-scores listbox?
Next up.....
2) *way more advanced, please try to follow me* Building upon #1....
Is there a way to 'detect' a particular keyword in a StringBuilder instance. Simply detect the keyword "leet" and return a nickname assigned to that keyword from a list.....
In other words...i pull a hi-score username as "MrLeetAmerica999" --> to.lower --> add to stringbuilder (remove #s / truncate to 10chars) --> now search "mrleetamer" for keywords contained in (c:\keywords.txt) -->
keywords.txt contains (in this format) keyword;nickname
Example: (1 per line in txt file)
leet;Mr Leet
jennifer;MsJenn
travis;Trav
So If keyword "leet" present in StringBuilder, return "Mr Leet" as final String --> If not then use the typical StringBuilder rules and print first 10 chars of membername (with #s and special chars removed)
If keyword "jennifer" present in StringBuilder, return "MsJenn" as final String --> If not then use the typical StringBuilder rules and print first 10 chars of membername (with #s and special chars removed)
If keyword "travis", present in StringBuilder, return "Trav" as final String --> If not then use the typical StringBuilder rules and print first 10 chars of membername (with #s and special chars removed)
Thanks for taking the time to read & understand my seemingly complex situation! And + rep to anyone willing to help!
P.S.
If you've come into this thread to make a comment like "why would you need to...." or "that doesn't make any sense" and suggest something completely different, without offering any examples...please take your superior attitude on to the next thread because I don't want to hear it.
I am pulling names from a list of hi-score players on a gamer spot i run with a friend. These names look like the following examples: 1) LOUiS1gaMer1dawg444 2) Leet__Homie 3) M4-bmw4LIFE 4) KISSMYBUTT1111
Here is my current code, which extracts the name from the element, formats it to lowercase, then uses a series of stringbuilder variables to format it/remove bad words/change to PG-rated words/remove #s
Code:
Dim username As String = WebBrowser1.Document.GetElementById("hiscore-user-0").GetAttribute("value")
username = New String(username.ToLower())
Dim humanized As New StringBuilder(username)
humanized.Replace("0", "")
humanized.Replace("1", "")
humanized.Replace("2", "")
humanized.Replace("3", "")
humanized.Replace("4", "")
humanized.Replace("5", "")
humanized.Replace("6", "")
humanized.Replace("7", "")
humanized.Replace("8", "")
humanized.Replace("9", "")
humanized.Replace("_", "")
humanized.Replace("-", "")
humanized.Replace("azz", "")
humanized.Replace("leet", "elite")
humanized.Replace("butt", "behind")
* CODE TO SEND --> humanized.ToString --> to be saved in my high-score listbox *
Now that's great for me, saves time & looks a lot cleaner than it used to...for posting to the HIGH-SCORES board. I used to have to enter it manually, all 300 ppl's names (and think of a nickname for each).
But you see the name lousgamerdawg from the resulting formatting....It's still too long to fit into my high-score list. It needs to be 10 or less characters.
Ok so here is the help i need.....
1) How do I truncate that instance of builder aka (humanized) down to 10 chars..before i convert to string & add to my high-scores listbox?
Next up.....
2) *way more advanced, please try to follow me* Building upon #1....
Is there a way to 'detect' a particular keyword in a StringBuilder instance. Simply detect the keyword "leet" and return a nickname assigned to that keyword from a list.....
In other words...i pull a hi-score username as "MrLeetAmerica999" --> to.lower --> add to stringbuilder (remove #s / truncate to 10chars) --> now search "mrleetamer" for keywords contained in (c:\keywords.txt) -->
keywords.txt contains (in this format) keyword;nickname
Example: (1 per line in txt file)
leet;Mr Leet
jennifer;MsJenn
travis;Trav
So If keyword "leet" present in StringBuilder, return "Mr Leet" as final String --> If not then use the typical StringBuilder rules and print first 10 chars of membername (with #s and special chars removed)
If keyword "jennifer" present in StringBuilder, return "MsJenn" as final String --> If not then use the typical StringBuilder rules and print first 10 chars of membername (with #s and special chars removed)
If keyword "travis", present in StringBuilder, return "Trav" as final String --> If not then use the typical StringBuilder rules and print first 10 chars of membername (with #s and special chars removed)
Thanks for taking the time to read & understand my seemingly complex situation! And + rep to anyone willing to help!
P.S.
If you've come into this thread to make a comment like "why would you need to...." or "that doesn't make any sense" and suggest something completely different, without offering any examples...please take your superior attitude on to the next thread because I don't want to hear it.