HackerRank Matching Word Boundaries Solution

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

One more thing to add, don’t straight away look for the solutions, first try to solve the problems by yourself. If you find any difficulty after trying several times, then look for the solutions. We are going to solve the  Regex HackerRank Solutions using  CPP, JAVA, PYTHON, JavaScript & PHP Programming Languages.

HackerRank Matching Word Boundaries Solution
HackerRank Matching Word Boundaries Solution

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.

HackerRank Matching Word Boundaries Solution

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 Solution in Cpp

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

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

HackerRank Matching Word Boundaries Solution in JavaScript

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

Matching Word Boundaries Solution 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 Chase2learn. This tutorial is only for Educational and Learning purposes.

Sharing Is Caring