Valid Word Abbreviation
Problem statement
Given a lowercase word and an abbreviation, determine whether the abbreviation represents the word.
A positive decimal number skips that many consecutive characters. A number may not start with 0.
Function
validWordAbbreviation(word: String, abbreviation: String) → booleanExamples
Example 1
word = "internationalization"abbreviation = "i12iz4n"return = trueThe numeric parts skip 12 and 4 characters, and every literal matches.
Example 2
word = "apple"abbreviation = "a2e"return = falseAfter skipping two characters, the abbreviation expects e where the word has l.
Constraints
1 <= word.length, abbreviation.length <= 100wordcontains lowercase English letters.abbreviationcontains lowercase English letters and digits.