Day 28: RegEx, Patterns, and Intro to Databases In Java | 30 Days Of Code | Hackerrank Programming Solutions

Hello Programmers/Coders, Today we are going to share solutions of Programming problems of 30 Days Of Code, HackerRank. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.

In this post, you will find the solution for Day 28: RegEx, Patterns, and Intro to Databases in Java-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

Link for the ProblemDay 28: RegEx, Patterns, and Intro to Databases – Hacker Rank Solution

Day 28: RegEx, Patterns, and Intro to Databases – Hacker Rank Solution


Today, we’re working with regular expressions. Check out the Tutorial tab for learning materials and an instructional video!

Consider a database table, Emails, which has the attributes First Name and Email ID. Given  rows of data simulating the Emails table, print an alphabetically-ordered list of people whose email address ends in .

Input Format

The first line contains an integer, , total number of rows in the table.
Each of the  subsequent lines contains  space-separated strings denoting a person’s first name and email ID, respectively.


  • Each of the first names consists of lower case letters  only.
  • Each of the email IDs consists of lower case letters ,  and  only.
  • The length of the first name is no longer than 20.
  • The length of the email ID is no longer than 50.

Output Format

Print an alphabetically-ordered list of first names for every user with a gmail account. Each name must be printed on a new line.

Sample Input


Sample Output

Day 28: RegEx, Patterns, and Intro to Databases – Hacker Rank Solution
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Day28RegExPatternsAndIntroToDatabases {
	public static void main(String[] args) {
		Scanner in = new Scanner(;
		int N = in.nextInt();
		List<String> list = new ArrayList<String>();
		for (int a0 = 0; a0 < N; a0++) {
			String firstName =;
			String emailID =;
			String regExPattern = "[a-z]";

			Pattern p = Pattern.compile(regExPattern);
			Matcher m = p.matcher(emailID);
			if (m.find()) {

		for (String string : list) {

Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker🙏.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock