We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Matching Anything But a Newline
Matching Anything But a Newline
Sort by
recency
|
387 Discussions
|
Please Login in order to post a comment
java solution
c++ soln
For JS
var Regex_Pattern = /^...\....\....\....$/g;
Let's break down the regular expression
^\S{3}\.\S{3}\.\S{3}\.\S{3}$
:^
: This asserts the start of the string.\S{3}
: This matches exactly three non-whitespace characters (\S
matches any non-whitespace character, and{3}
specifies that exactly three of such characters should be matched).\.
: This matches a period (dot) character literally. The backslash\
is an escape character to ensure that the dot is treated as a literal character and not as a special regex character.\S{3}
: This matches exactly three non-whitespace characters again.\.
: This matches another period (dot) character literally.\S{3}
: This matches exactly three non-whitespace characters again.\.
: This matches another period (dot) character literally.\S{3}
: This matches exactly three non-whitespace characters again.\.
: This matches another period (dot) character literally.\S{3}
: This matches exactly three non-whitespace characters again.$
: This asserts the end of the string.So, overall, this regular expression pattern matches strings that have the following structure: "XXX.XXX.XXX.XXX", where each "X" represents any non-whitespace character and there are exactly three such characters separated by periods.
I don't get the problem being asked. First it tells you "anything except newline" then it tells strings matching "abc.def...." then it says "a", "b" etc are variable. What the f are we supposed to do?
Is it so difficult to say "given input write a pattern to match output "??