ankidroid/Anki-Android — pull request #153 by pabloem (2014-01-02 05:36:46+00:00)
Title: Iss1852 wildcards fields

Corrected the code that is in charge of matching regular expressions of fields. The problem was that we needed to use different syntax for SQL Lite and the Java Pattern class, when matching the expressions.

Also, removed the line:
```
String regex = Pattern.quote(val).replace("\\Q_\\E", ".").replace("\\Q%\\E", ".*");
```
Because the regex matching already makes sure that the string matches exactly.

Also, created the pattern outside of the loop, to make sure only one is created:
```
Pattern thePattern = Pattern.compile(val, Pattern.CASE_INSENSITIVE);
while(...
```
Also made sure to test several cases of field search. Any comments are welcome!

Answering Flerda's comments on the previous pull request:
```
+ String sqlVal = val.replace("*","%");
+ val = val.replace("_", ".");
+ val = val.replace("*", ".*");
```
This is necessary because we check the string twice: Once in SQLLite, using the LIKE clause, and once more with the Pattern class, using Java standard regular expressions.
In SQLLite, the LIKE clause uses '_' and '%' as wildcards for any character, and any sequence of characters respectively.
In Java REGEX, '.' and '\*' are used as wildcards for any character, and any number of repetitions of the character on the left: so for any sequence of characters we need to use '.*' in Java REGEX standard.

Also, I corrected the indentation with the automatic function in Eclipse. I hope that is enough.

Finally, I reverted the erroneous change on the classpath file in the tests directory.