HackerRank Matching Word Boundaries Solution

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

HackerRank Matching Word Boundaries Solution
HackerRank Matching Word Boundaries 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 Word Boundaries Solution

\b
\b 
assert position at a word boundary.

Three different positions qualify for word boundaries :
► Before the first character in the string, if the first character is a word character.
► Between two characters in the string, where one is a word character and the other is not a word character.
► After the last character in the string, if the last character is a word character.

Task

You have a test String S.
Your task is to write a regex which will match word starting with vowel (a,e,i,o, u, A, E, I , O or U).
The matched word can be of any length. The matched word should consist of letters (lowercase and uppercase both) only.
The matched word must start and end with a word boundary.

Note

This is a regex only challenge. You are not required to write a code.
You have to fill the regex pattern in the blank (_________).

HackerRank Matching Word Boundaries Solutions in Cpp

HackerRank Matching Word Boundaries Solutions in Java

public class Solution {    
    public static void main(String[] args) {
        
        Regex_Test tester = new Regex_Test();
        tester.checker("\\b[aeiouAEIOU][a-zA-Z]*\\b");
    
    }
}

HackerRank Matching Word Boundaries Solutions in Python

Regex_Pattern = r'\b[aeiouAEIOU][a-zA-Z]*\b'   # Do not delete 'r'.

HackerRank Matching Word Boundaries Solutions in JavaScript

var Regex_Pattern = /\b[aeiouAEIOU][a-zA-Z]*\b/;

HackerRank Matching Word Boundaries Solutions in PHP

$Regex_Pattern = "/\b[aeiou][a-z]*\b/i"; //Do not delete '/'. Replace __________ with your regex. 

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

Next: HackerRank Capturing & Non-Capturing Groups Solution

Leave a Reply

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