Jump to content

A script to reverse two words in one line


Recommended Posts

Trying to figure out how to make a autoit script to have one input box that I can put

"FirstName Lastname" then I hit OK button

and it out puts the

"LastName FirstName" to another string.

Any help would be appreciated with this.

I want to reverse the two words in the input box.

Thank You

Rene

Link to comment
Share on other sites

There is no reliable way to split a whole name. What if the persons name is Mary Ann O' Flannigan, or John Jacob Jingleheimer Schmidt?

Ask for first, middle and last names seperately.

$string = "FirstName Lastname"
$reversed = StringRegExpReplace($string,"\A(.*)\h(.*)\Z", "$2 $1")
MsgBox(0,"",$reversed)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...