HackerRank Matching Ending Items Solution

Hello Programmers, In this post, you will know how to solve the HackerRank Matching Ending Items Solution. This problem is a part of the Regex HackerRank Series.

HackerRank Matching Ending Items Solution
HackerRank Matching Ending Items Solutions

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Hackerrank by yourself. If you find any difficulty after trying several times, then you can look for solutions.

HackerRank Matching Ending Items Solutions

$
The $ boundary matcher matches an occurrence of a character/character class/group at the end of a line.

Task

Write a RegEx to match a test string, S, under the following conditions:

  • S should consist of only lowercase and uppercase letters (no numbers or symbols).
  • S should end in s.

This is a RegEx-only challenge, so you are not required to write any code.
Simply replace the blank (_________) with your RegEx pattern.

HackerRank Matching Ending Items Solutions in Cpp

HackerRank Matching Ending Items Solutions in Java

public class Solution {    
    public static void main(String[] args) {
        
        Regex_Test tester = new Regex_Test();
        tester.checker("^[a-zA-Z]*(s|es)$"); // Use \\ instead of using \ 
    
    }
}

HackerRank Matching Ending Items Solutions in Python

Regex_Pattern = r'^[a-zA-Z]*e?s$'	# Do not delete 'r'.

HackerRank Matching Ending Items Solutions in JavaScript

var Regex_Pattern = /^[a-zA-Z]*e?s$/;

HackerRank Matching Ending Items Solutions in PHP

$Regex_Pattern = "/^[a-zA-Z]*e?s$/"; //Do not delete '/'. Replace __________ with your regex. 

Disclaimer: This problem (Matching Ending Items) is generated by HackerRank but the Solution is Provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.

Next: HackerRank Detect HTML Tags Solution

Leave a Reply

Your email address will not be published. Required fields are marked *