Sign in to follow this  
Followers 0
caramen

[SOLVED]Question about User name and logins

2 posts in this topic

#1 ·  Posted (edited)

Hello guys I already done that in the past but i cant remember how i did.

Local $sAnswer = InputBox("User name", "Plz enter the user name and lastname", "Answer", "")

When the answer gonna be Tony MONTANA

How can i transform into TMontana

I guesse it s somthing with split to array or ?

Edited by caramen

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Something like this, perhaps:

Local $sQuery = InputBox("User name", "Plz enter the user name and lastname", "Answer", "")
Local $aSplit = StringSplit($sQuery, " ")
    If IsArray($aSplit) Then
        ConsoleWrite(StringLeft($aSplit[1], 1) & StringLeft($aSplit[2], 1) & StringLower(StringTrimLeft($aSplit[2], 1)) & @CRLF)
    EndIf

Now, I am sure you could do it with Regex, unfortunately regex makes my eyes bleed. This is as close as I could come. Perhaps one of our regex geniuses will wander by and improve upon it. Only works if the last name is not all caps.

#include <StringConstants.au3>

Local $sQuery = InputBox("User name", "Plz enter the user name and lastname", "Answer", "")
Local $aSplit = StringRegExp($sQuery, '[A-Z]+[a-z]+', $STR_REGEXPARRAYGLOBALMATCH)
Local $aAnswer = StringLeft($aSplit[0], 1) & $aSplit[1]
ConsoleWrite($aAnswer & @CRLF)

 

Edited by JLogan3o13
1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0