4 ms·
Every comment here at time of writing is from people thinking that this is a way of searching the web using regular expressions. It is not. It is a way of taki
by mike-cardwell 12y ago
Every comment here at time of writing is from people thinking that this is a way of searching the web using regular expressions. It is not.
It is a way of taking a regular expression and an input and then applying that regular expression to that input. In this particular example it takes the regular expression:
/(?x: (\w+) \s (\w+) )/
And applies it to:
"hacker news"
And then spits out the result:
"hacker | news"
Representing the two captured results.
- Illniyar 12y agoWhat is the use for this?
- mike-cardwell 12y agoTesting regular expressions
- oneeyedpigeon 12y agoThank you. Can you explain what "?x:" does? Searching for regular expressions syntax (another thing this doesn't do) is quite tricky.
- joosters 12y agoIt's another way of specifying a regular expression modifier, normally given at the end of a regex. In this case, 'x' means "Extend your pattern's legibility by permitting whitespace and comments"
- pbhjpbhj 12y agohttp://regex101.com/ http://regex101.com/ tells me: >"x modifier: extended. Spaces and text after a # in the pattern are ignored" // The other explainers I had to hand failed and/or called it an error.
- squeaky-clean 12y agoIt depends on the flavor of regex being used. Try switching regex101 to JS or PY mode, and you'll see that the x modifier isn't supported.
- easytiger 12y agoSo.... it executes a regex?
- mike-cardwell 12y agoYes. It's just a normal search term. Except for in the "Answers" section that DuckDuckGo sometimes provides when it thinks it knows the answer to what you're asking, it supplies the results of executing the regex.
- zeratul 12y agoI agree. What the internet needs is semantics not regular expressions. If there is a need for regular expression, it's only because semantics is not working, for example, the search engine does not have all the synonyms so I might write "do|does|done". We should be focusing more on textual query expansion (if the query hides some background knowledge), auto-tagging of web pages (if the web pages assume some background knowledge) and clever disambiguation of queries (if we don't know which background knowledge tap into).