geekelo / geekelo/dsa_practice

JavaScript pattern matching

Open
#11 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Given a string text and a pattern, evaluate if a given text string matches a specified pattern utilizing special characters for pattern matching. The pattern matching should adhere to the following rules. The symbol, full stop, represents any individual character. The symbol, asterisk, indicates zero or more occurrences of a character that appears just before it. Return true if the pattern corresponds exactly to the entire text string. If not, return false. Note, your implementation should be dependent on regular expression or similar convenience libraries. Your implementation should be able to handle all hidden test cases correctly. Example 1, the input text is aa. Pattern is a. Output is false. Explanation, the symbol a does not match the full text aa. Example 2, text is aa, pattern is a. Output, okay, pattern is a asterisk. Output is true. Explanation, the pattern a asterisk can represent aa as asterisk allows for repeating a. Example 3, input ab asterisk dot asterisk. Output is true. Explanation, the pattern dot asterisk can match any sequence of characters. Okay, constraints, one is less than equals text dot length less than equals 20. One is less than equals pattern dot length less than equals 20. Text contains only lowercase English letters. Pattern contains only lowercase English letters, dots and asterisks. It is guaranteed for each appearance of the character asterisk. There will be a previous valid character to match. Okay, and I'll be solving this using JavaScript. Alright.

![Image](https://github.com/geekelo/dsa_practice/assets/102464578/239b2b1f-cc00-417e-98e1-e410f21b3c08)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.