If in case you don’t know about Unicode Characters then head over to Wikipedia to learn these – Unicode Characters Wikipedia.
You re right
Which is not what programmer have intended. This is just an example, there does exist many other this kind of scenarios.
coding = "Computer Science Hub"; coding.length; (20) //would return length of "Computer Science Hub" coding.chartAt(0); (C) //would return character at position zero in string coding.substring(1, 3); (om) //would return string of characters starting from position 1 to position 3(Not including it) coding.slice(1,3); (om) //kind of similar as .substring coding.toUpperCase(); (COMPUTER SCIENCE HUB) //would change whole string to uppercase letters
Doing Pattern Matching is what I do kind of each day, while writing code. Either it be comparing two texts or finding something out of large text(thousands of words) Pattern Matching is the way to go.
Note – If in case your’s not aware of how to make a pattern or Regular Expression, then you’re in trouble as this is one of most important aspect of programming. So better learn it, Regexone has awesome free tutorial for this you can check it out – Introduction to Regex.
- /^Programming/ (Match each letter of Programming word at the start of a string)
- /[1-9][0-9]*/ (Match a non-zero digit, followed by any number of digits)
- var text = “testing: 1, 2, 3”; (Sample text)
- var pattern = /\d+/g; (Pattern matching all occurring of one or more digits)
- pattern.text(text); (Returns => true, meaning there does exist a match)
- text.search(pattern); (Returns => 9, position of first matching)
- text.match(pattern); (Returns => [“1”, “2”, “3”] all matches characters)
- text.replace(pattern. “Computer”); (Returns => “testing: #, #, #”)
- text.split(/\D+/); (Returns => [“”, “1”, “2”, “3”] split string on non-digits)