Question:You are writing an application to process data contained in a text form. Each file contains information about a single customer. The following is a sample form:
First Name: Tom
Last Name: Perham
Address: 123 Pine St.
City: Springfield
State: MA
Zip: 01332
You have read the form data into the String variable s. Which of the following code samples correctly stores the data portion of the form in the fullName, address, city, state, and zip variables? - VB.NET
 

A Dim p As String = "First Name: (?<firstName>.*$)\n" + _
"Last Name: (?<lastName>.*$)\n" + _
"Address: (?<address>.*$)\n" + _
"City: (?<city>.*$)\n" + _
"State: (?<state>.*$)\n" + _
"Zip: (?<zip>.*$)"
Dim m As Match = Regex.Match(s, p, RegexOptions.Multiline)
Dim fullName As String = m.Groups("firstName").ToString + " " + _
m.Groups("lastName").ToString
Dim address As String = m.Groups("address").ToString
Dim city As String = m.Groups("city").ToString
Dim state As String = m.Groups("state").ToString
Dim zip As String = m.Groups("zip").ToString
 

B Dim p As String = "First Name: (?<firstName>.*$)\n" + _
"Last Name: (?<lastName>.*$)\n" + _
"Address: (?<address>.*$)\n" + _
"City: (?<city>.*$)\n" + _
"State: (?<state>.*$)\n" + _
"Zip: (?<zip>.*$)"
Dim m As Match = Regex.Match(s, p)
Dim fullName As String = m.Groups("firstName").ToString + " " + _
m.Groups("lastName").ToString
Dim address As String = m.Groups("address").ToString
Dim city As String = m.Groups("city").ToString
Dim state As String = m.Groups("state").ToString
Dim zip As String = m.Groups("zip").ToString
 

C Dim p As String = "First Name: (?<firstName>.*$)\n" + _
"Last Name: (?<lastName>.*$)\n" + _
"Address: (?<address>.*$)\n" + _
"City: (?<city>.*$)\n" + _
"State: (?<state>.*$)\n" + _
"Zip: (?<zip>.*$)"
Dim m As Match = Regex.Match(s, p, RegexOptions.Multiline)
Dim fullName As String = m.Groups("<firstName>").ToString + " " + _
m.Groups("<lastName>").ToString
Dim address As String = m.Groups("<address>").ToString
Dim city As String = m.Groups("<city>").ToString
Dim state As String = m.Groups("<state>").ToString
Dim zip As String = m.Groups("<zip>").ToString
 

D Dim p As String = "First Name: (?<firstName>.*$)\n" + _
"Last Name: (?<lastName>.*$)\n" + _
"Address: (?<address>.*$)\n" + _
"City: (?<city>.*$)\n" + _
"State: (?<state>.*$)\n" + _
"Zip: (?<zip>.*$)"
Dim m As Match = Regex.Match(s, p)
Dim fullName As String = m.Groups("<firstName>").ToString + " " + _
m.Groups("<lastName>").ToString
Dim address As String = m.Groups("<address>").ToString
Dim city As String = m.Groups("<city>").ToString
Dim state As String = m.Groups("<state>").ToString
Dim zip As String = m.Groups("<zip>").ToString 

+ Answer
+ Report
Total Preview: 1476

Copyright © 2024. Powered by Intellect Software Ltd