Thamizhiniyan C S
HomeWriteupsResourcesCheatsheets
HackerRank
HackerRank
  • HackerRank
  • Linux Shell
    • Bash
    • Text Processing
      • Cut
      • Head
      • Middle
      • Tail
      • Tr
      • Sort
      • Uniq
      • Paste
    • Arrays In Bash
    • Grep Sed Awk
      • Grep
      • Sed
      • Awk
  • Regex
    • Introduction
    • Character Class
    • Repetitions
    • Grouping and Capturing
    • Backreferences
    • Assertions
    • Applications
  • Python
    • Introduction
    • Basic Data Types
    • Strings
    • Sets
    • Math
    • Itertools
    • Collections
    • Date and Time
    • Errors and Exceptions
    • Classes
    • Built-Ins
    • Python Functionals
    • Regex and Parsing
    • XML
    • Closures and Decorators
    • Numpy
    • Debugging
  • C
    • Introduction
    • Conditionals and Loops
    • Arrays and Strings
Powered by GitBook
On this page
  • Matching Word Boundaries
  • Capturing and Non-Capturing Groups
  • Alternative Matching

Was this helpful?

  1. Regex

Grouping and Capturing

PreviousRepetitionsNextBackreferences

Last updated 1 year ago

Was this helpful?

Matching Word Boundaries

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.

\b[aeiouAEIOU][a-zA-Z]*\b

Capturing and Non-Capturing Groups

You have a test String S. Your task is to write a regex which will match S with the following condition:

  • S should have 3 or more consecutive repetitions of ok.

(ok){3,}

Alternative Matching

Given a test string, s, write a RegEx that matches s under the following conditions:

  • must start with Mr., Mrs., Ms., Dr. or Er..

  • The rest of the string must contain only one or more English alphabetic letters (upper and lowercase).

^(Mr\.|Mrs\.|Ms\.|Dr\.|Er\.)[a-zA-Z]+$
Solve Programming Questions | HackerRankHackerRank
Logo