question has to do with Java programing. I am attempting to do a Regex Lab and read in a text file and validate whether or not it is license plate. The problem is that the text file is read and one of the examples is "ABC 1234", but it reads "ABC" instead of the whole line. I will attach the screenshots of what I have so fa

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

My question has to do with Java programing. I am attempting to do a Regex Lab and read in a text file and validate whether or not it is license plate. The problem is that the text file is read and one of the examples is "ABC 1234", but it reads "ABC" instead of the whole line. I will attach the screenshots of what I have so far. 

File Edit View Build Project Settings Tools Window Help
В
All Files
Sort B...
1 АВС 1234
2 HJ3 350P
3 ) (4 POkj
4 490nnIOK
/Object Oriented Pro
5 86R TLM9
BigIntBigDecimalLab.
J BigIntBigDecimalLab.
BiglntegerBig Decima
ClassRelationshipLab
J ClassRelationshipLab
6 tYU 97M
7 QAU IFB
8 pI9 3fX
9 ZI7 D60
10 L82 HWC
Clock.class
Clock.java
idbb.txt
regexlab.txt
StringBuilderLab.clas
J StringBuilderLab.java
StringRegexLab.class
U StringRegexLab.java
Time.class
Time.java
J WrapperClassesExam
G
CSD
G
CSD
G
CSD
G
G
G
|G
G
G
CSD
G
G
CSD
G
CSD
G
G
G
G
G
G
CSD
G
|G
G
G
G
G
G
CSD
G
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
Compile Messages JGRASP Messages
Run I/0
Interactions
The proposed license plate is ) ( 4.
This is not a valid license plate.
The proposed license plate is POkj.
This is not a valid license plate.
The proposed license plate is 490nnIOK.
This is not a valid license plate.
End
Clear
Help
Browse
Find
Debug Workbench
Line:1
Col:1
Code:65
Top:1
ovs BLK
Transcribed Image Text:File Edit View Build Project Settings Tools Window Help В All Files Sort B... 1 АВС 1234 2 HJ3 350P 3 ) (4 POkj 4 490nnIOK /Object Oriented Pro 5 86R TLM9 BigIntBigDecimalLab. J BigIntBigDecimalLab. BiglntegerBig Decima ClassRelationshipLab J ClassRelationshipLab 6 tYU 97M 7 QAU IFB 8 pI9 3fX 9 ZI7 D60 10 L82 HWC Clock.class Clock.java idbb.txt regexlab.txt StringBuilderLab.clas J StringBuilderLab.java StringRegexLab.class U StringRegexLab.java Time.class Time.java J WrapperClassesExam G CSD G CSD G CSD G G G |G G G CSD G G CSD G CSD G G G G G G CSD G |G G G G G G CSD G CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD Compile Messages JGRASP Messages Run I/0 Interactions The proposed license plate is ) ( 4. This is not a valid license plate. The proposed license plate is POkj. This is not a valid license plate. The proposed license plate is 490nnIOK. This is not a valid license plate. End Clear Help Browse Find Debug Workbench Line:1 Col:1 Code:65 Top:1 ovs BLK
File Edit View Build Project Settings Tools Window Help
В
All Files
Sort B...
{
list[i] = list[i].replaceAll("\\s", "");
System.out.println(list[i]);
}
61
62
|/Object Oriented Pro
65
BigIntBig DecimalLab.
O BigIntBigDecimalLab.
O BiglntegerBigDecima
ClassRelationshipLab
J ClassRelationshipLab
66
67
File myFile
Scanner in
new File("regexlab.txt"); // Declares a variable of type File
new Scanner(myFile);
68
69
70
String lp = " ";
Clock.class
71
while (in.hasNext())
{
72
Clock.java
73
idbb.txt
74
= in.next();
regexlab.txt
StringBuilderLab.clas
U StringBuilderLab.java
StringRegexLab.class
U StringRegexLab.java
lp
System.out.println("The proposed license plate is
if(lp.matches ("[A-Z0-9]{3} [A-Z0-9]{4}"))
{
System.out.println("This is a valid license plate.");
}
else
75
+ lp +
') ;
76
77
78
79
Time.class
81
System.out.println("This is not a valid license plate.");
Time.java
J WrapperClassesExam
}// close while loop
in.close() ;
82
83
84
}// end of main
86 }// end of StringRegexLab
85
G
CSD
G
CSD
G
G
CSD
G
G
CSD
G
CSD
G
CSD
G
CSD
G
G
G
G
CSD
G
G
CSD
G
G
G
G
G
G
G
G
G
CSD
G
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
CSD
Compile Messages JGRASP Messages
Run I/0
Interactions
The proposed license plate is ) ( 4.
This is not a valid license plate.
The proposed license plate is POkj.
This is not a valid license plate.
The proposed license plate is 490nnIOK.
This is not a valid license plate.
End
Clear
Help
Browse
Find
Debug Workbench
Line:76
Col:41 Code:65
Top:61
ovS BLK
RI
4 5 6
00 00 00 O 00 OO 0
666 66
Transcribed Image Text:File Edit View Build Project Settings Tools Window Help В All Files Sort B... { list[i] = list[i].replaceAll("\\s", ""); System.out.println(list[i]); } 61 62 |/Object Oriented Pro 65 BigIntBig DecimalLab. O BigIntBigDecimalLab. O BiglntegerBigDecima ClassRelationshipLab J ClassRelationshipLab 66 67 File myFile Scanner in new File("regexlab.txt"); // Declares a variable of type File new Scanner(myFile); 68 69 70 String lp = " "; Clock.class 71 while (in.hasNext()) { 72 Clock.java 73 idbb.txt 74 = in.next(); regexlab.txt StringBuilderLab.clas U StringBuilderLab.java StringRegexLab.class U StringRegexLab.java lp System.out.println("The proposed license plate is if(lp.matches ("[A-Z0-9]{3} [A-Z0-9]{4}")) { System.out.println("This is a valid license plate."); } else 75 + lp + ') ; 76 77 78 79 Time.class 81 System.out.println("This is not a valid license plate."); Time.java J WrapperClassesExam }// close while loop in.close() ; 82 83 84 }// end of main 86 }// end of StringRegexLab 85 G CSD G CSD G G CSD G G CSD G CSD G CSD G CSD G G G G CSD G G CSD G G G G G G G G G CSD G CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD CSD Compile Messages JGRASP Messages Run I/0 Interactions The proposed license plate is ) ( 4. This is not a valid license plate. The proposed license plate is POkj. This is not a valid license plate. The proposed license plate is 490nnIOK. This is not a valid license plate. End Clear Help Browse Find Debug Workbench Line:76 Col:41 Code:65 Top:61 ovS BLK RI 4 5 6 00 00 00 O 00 OO 0 666 66
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education