Home:ALL Converter>What is the purpose of Lucene's @ (anystring) optional regexp syntax

What is the purpose of Lucene's @ (anystring) optional regexp syntax

Ask Time:2016-02-23T01:13:22         Author:femtoRgon

Json Formatter

I noticed this optional Lucene regex syntax, and wasn't sure what it's purpose was. When performing a regex query in Lucene, you can enable @ as a special character with the ANYSTRING flag, like so:

new RegexpQuery(new Term("text", "abc@"), RegExp.ANYSTRING);

Tried a few things, and it seems to behave the same as:

new RegexpQuery(new Term("text", "abc.*"));

The ElasticSearch docs note that it can be used with other optional syntax to provide an "anything except" query, such as:

new RegexpQuery(new Term("text", "ab(@&~(cd))"), RegExp.ALL);

But even this seems to work fine with .* instead:

new RegexpQuery(new Term("text", "ab(.*&~(cd))"), RegExp.ALL);

So why does this optional @ syntax exist? Is it just an alias for .*, or is there some subtle difference between the two that I am missing?

Author:femtoRgon,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/35559731/what-is-the-purpose-of-lucenes-anystring-optional-regexp-syntax
yy