我已将搜索添加到我的代码中,现在我想知道一件事。
我正在使用 Parse.com 的方法:
query.whereContains("my_strings_from_Parse", text_from_EditText.toLowerCase())
我已经将 EditText 中的文本转为小写,但现在是否需要将 Parse.com 中的字符串转为小写。
你知道该怎么做吗?
Intent intent = getIntent();
String query = intent.getStringExtra("query");
ParseQuery<Animal> squery = ParseQuery.getQuery(Animal.class);
squery.whereContains("animal", query.toLowerCase()); //I need to make content of //"animal"
最佳答案
您可以使用带有不区分大小写修饰符的正则表达式,如here所述:
public ParseQuery<T> whereMatches(String key, String regex, String modifiers)
Add a regular expression constraint for finding string values that match the provided regular expression. This may be slow for large datasets.
Parameters:
key
- The key that the string to match is stored in.
regex
- The regular expression pattern to match.
modifiers
- Any of the following supported PCRE modifiers:
i
- Case insensitive search
m
- Search across multiple lines of inputReturns: Returns the query, so you can chain this call.
关于java - 如何根据文本大小写独立获取对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21660394/