topical media & game development
basic-regex-20-ReverseName.htm / htm
<html>
<head>
<title>Reverse Surname and First Name</title>
<script language="vbscript" type="text/vbscript">
Function ReverseName
Dim myRegExp, TestName, Match
Set myRegExp = new RegExp
myRegExp.Pattern = "(\S+)(\s+)(\S+)"
TestString = InputBox("Enter your name below, in the form" & VBCrLf & _
"first name, then a space then last name." & VBCrLf & "Don't enter an initial or middle name.")
Match = myRegexp.Replace(TestString, "$3,21")
If Match <> "" Then
MsgBox "Your name in last name, first name format is:" & VBCrLf & Match
Else
MsgBox "You didn't enter your name." & VBCrLF & "Press OK then F5 to run the example again."
End If
End Function
</script>
</head>
<body onload="ReverseName">
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.