topical media & game development

talk show tell print

basic-regex-20-ReverseNameStricter.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 = "^([A-Za-z]+)(\s+)([A-Za-z]+)"
  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."_
   & "Any extra information will result in an error.")
  Match = myRegexp.Replace(TestString, "$3,21")
  If Match <> TestString Then
    MsgBox "Your name in last name, first name format is:" & VBCrLf & Match
  Else
    MsgBox "You didn't enter your name in the format requested." & VBCrLF _
    & "You may have entered no data, omitted part of your name," & VBCrLf _
    & "or entered extra data." & VBCrLf & 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.