Skip to content
  • Home
  • News
  • Sample Code
  • How To
  • Tutorial
  • Assignment Help!

Student Assignment Help

Assignment Solution @ Assignment Help on Fiverr.com

  • Home
  • News
  • Sample Code
    • C/C++ Sample Code
      • C in Linux
        • Linux Kernel Module
      • C in Windows
    • Java Sample Code
    • Python Sample Code
    • New Jersey Standard ML (SML/NJ)
    • Oracle Sample Code
    • Database Analysis and Design Sample
  • How To
    • HTML-XML-CSS
    • Java
    • MySQL
    • Oracle
    • Linux RedHat
  • Tutorial
    • System Analysis and Design
    • Data Flow Diagram DFD
    • Database Analysis and Design
    • C/C++ Language
    • WordPress
      • WordPress Basic
      • WordPress Security
  • Assignment Help!

Regular Expressions in Java

Posted on 2018-12-172018-12-17 By Presto Bear No Comments on Regular Expressions in Java

Download Solution: Click to Download Solution
Solution File Name: SrcCode2CC.zip
Unzip Password: prestobear.com

Match IPv4 Addresses (50 points total)
Work on the following tasks in the order they are given. The order is designed to help you
incrementally build up a complete regex.
1. For this part you will complete the IPV4_ADDRESS_REGEX static variable in
class InternetAddressValidator. You will write your tests in
the TestIsIPv4Address JUnit class.
2. (30 points) Write, and thoroughly test, a regular expression that handles IPv4 addresses, e.g.,
“160.010.025.006”. For now, handle IP addresses where:
1. All octets are exactly 3 digits (i.e., octets in the range of 0-99 are left-padded with
zeroes).
2. There is no checking of invalid IP addresses, i.e., addresses like “500.400.123.456” will
pass.
3. (15 points) Modify your IPv4 regex so that it allows 1 – and 2-digit octets. E.g., “192.168.1.15”
will now match. Make sure you add unit tests to handle these cases.
4. (5 points) Modify your IPv4 regex so that it only allows valid IP addreses, i.e., those with
octets in the 0-255 range. Make sure you add unit tests to handle these cases.

Match IPv4 Subnet Addresses (40 points total)
Again, work on the following tasks in the order they are given.
1. For this part you will complete the SUBNET_ADDRESS_REGEX static variable in
class InternetAddressValidator. You will write your tests in
the TestIsSubnetAddress JUnit class.
2. (15 points) Write, and thoroughly test, a regular expression that handles simple subnet
addresses, e.g.,
1. 255.255.255.255
2. 255.255.255.0
3. 255.255.0.0
4. 255.0.0.0
5. 0.0.0.0
3. (10 points) Modify your regex so that it handles the “1 -0” break in the fourth octet, meaning it
handles addresses like:
1. 255.255.255.128
2. 255.255.255.192
3. 255.255.255.224
4. etc
Hint: use to your advantage the fact that this last octet of numbers will be one of: 0, 128,
192, 224, 240, 248, 252, 254, or 255 — “OR” is your friend here!
Make sure you test this part thoroughly.
4. (10 points) Modify and test your regex so that the “1 -0” break is handled in the 3rd octet as
well as the fourth. Don’t be afraid to add a special “third octet” case here — it might be simpler
than trying to “fix” what you already have.
5. (5 points) Modify and test your regex so that it handles the “1 -0” break in the first and second
octets.

Match IPv6 Addresses (10 points total)
Again, work on the following tasks in the order they are given.
1. For this part you will complete the IPV6_ADDRESS_REGEX static variable in
class InternetAddressValidator. You will write your tests in
the TestIsIPv6Address JUnit class.
2. (5 points) Write, and thoroughly test, a regular expression that handles full-length IPv6
addresses (i.e., those without the “double colons”). You may assume every field between
colons is exactly four hex digits (left-padded with zeros if necessary).
3. (2 points) Modify your regex so fields can have 1, 2, 3, or 4 hex digits (i.e., padding-withzeroes is not required, but still allowed). Write appropriate tests for these cases.
4. (1 point) Modify and test your regex so that it may have “double colons” at the beginning of an
IPv6 address (representing one or more fields of all-zeroes). Again, don’t be afraid to use
“OR” and add a special case for this!
5. (1 point) Modify and test your regex so that it may have “double colons” at the end of the IPv6
address.
6. (1 point) Modify and test your regex so that it may have “double colons” in the middle of an
IPv6 address.

Assignment Help!!!
Java Sample Code

Post navigation

Previous Post: Java Program to draw the Fibonacci Square Spiral
Next Post: Project 1: Babble (Single-Player Scrabble Clone)

Leave a Reply Cancel reply

You must be logged in to post a comment.

Assignment Help!!!

Key Posts

  • Chapter 5 – Crow’s Foot Notation
  • [SOLVED] Could not find this item. This is no longer located
  • Linux command to get Tomcat PID
  • Case Study: Entity Relationship Diagram (ERD) for Student Registration System
  • Sample Java Program for Triangle
Assignment Help!!!

Recent Posts

  • Windows 10: How to start Command Prompt as Admin and Terminate a process
  • Java How to Trust all Email Server
  • [Solved]: Windows 10 100% Disk Usage
  • Weddings, Parties, Everything Catering Services System
  • CSC/CPE 3350 Lab 4 Part 1 – Recursive File Search
  • Zayed University
  • Kitchen Gadgets
  • Food Ordering System
  • Investment bank XYZ Ltd
  • CSC/CPE 3350 Lab 3 – The Falcon Shell
  • CSC/CPE 3350 Lab 2
  • Analyzing Cost and Benefit: Campus Bikes
  • Emirates Top Auto Parts
  • Sports News
  • Workington Council
Assignment Help!!!

Copyright © 2022 Student Assignment Help.