java - 如何根据文本大小写独立获取对象

标签 java android string parse-platform android-search

我已将搜索添加到我的代码中,现在我想知道一件事。

我正在使用 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 input

Returns: Returns the query, so you can chain this call.

关于java - 如何根据文本大小写独立获取对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21660394/

相关文章:

android - Android Studio 和 Gradle 未知类 'Object' 的 Proguard 说明

Java 8 字符串垃圾收集

java - 在 ssh 服务器上打开 channel

android - 如何在Android中检索SIM卡IMSI?

java - 如何使用点幻灯片注册 Activity

java - 从Java中的另一个字符串列表中替换字符串的最后一个子字符串的最有效方法

java - 删除特殊字符前后的空格

java - 如何可靠地判断 Java 中的套接字何时完成读取?

java - Java中两个String对象之间使用+运算符是怎么实现的?

java - 如何在Java中使用Dropwizard获取swagger.json