The dot (
.) matches anything (except for a newline).
Note: If you want to match (
In Java, use
.) in the test string, you need to escape the dot by using a slash \..In Java, use
\\. instead of \..
Task
You have a test string .
Your task is to match the pattern , where each variable can be any single character except the newline.
Your task is to match the pattern , where each variable can be any single character except the newline.
Note
This is a regex only challenge. You are not required to write any code.
You only have to fill in the regex pattern in the blank (
You only have to fill in the regex pattern in the blank (
_________).
------------------------------------------------------------------------------------------------------
Matching Anything But a Newline - Hacker Rank Solutions
Problem Tester's code :
regex_pattern = '^.{3}\\..{3}\\..{3}\\..{3}$'
the pattern explicitly and put at the end of the regex to match the end of the input string:
regex_pattern = '...\....\....\....$'
No comments:
Post a Comment