简体   繁体   English

我想将表单中的用户输入与查询的数据进行比较。 但我希望它不区分大小写。 我怎么做?

[英]I want to compare the user input from my form to the queried data. but I want it not to be case sensitive. how do I do that?

/* compares the values of txtOrigin and txtDestination to the query variables assuming it matches / / * 假设txtOrigin和txtDestination的值与查询变量匹配,则将其与 /

                if((origin.getText().toString().matches(queryOrigin))
                        && (destination.getText().toString().matches(queryDestination)))
                {
                //proceed to route found layout
                    Intent openRouteFound = new Intent("com.icommute.feu.RouteFound");
                    startActivity(openRouteFound);
                }

            /**compares the values of txtOrigin 
            and txtDestination to the query 
            variables assuming it doesn't match*/
                else
                {
                //proceed to no routes found layout
                    Intent openNoRoute = new Intent("com.icommute.feu.NoRoute");
                    startActivity(openNoRoute);
                }

Please try that: 请尝试:

 if((origin.getText().toString().equalsIgnoreCase(queryOrigin))
      && (destination.getText().toString().equalsIgnoreCase(queryDestination)))
 {
    ...
 }

use .equalsIgnoreCase() method eg: 使用.equalsIgnoreCase()方法,例如:

if((origin.getText().toString().equalsIgnoreCase(queryOrigin))
                    && (destination.getText().toString().equalsIgnoreCase(queryDestination)))
            {

} }

Try this 尝试这个

origin.getText().toString().matches("(?i)" + queryOrigin) . origin.getText().toString().matches("(?i)" + queryOrigin)

This will make regex CASE_INSENSITIVE 这将使正则表达式为CASE_INSENSITIVE

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想将我的php数据库中的数据添加到我的复选框中我该怎么做? - I want to add data from my php database into my checkbox how can i do that? 我希望我的应用程序在用户单击“呼叫”按钮时运行。 我怎样才能做到这一点? - I want my app to run when the user clicks on the call button. How can I do that? 如何设置将在我想要为 id 做的表单上预填的值 - How to set value that will prefilled on form i want to do for id 我想在我的android布局中执行此操作 - I want to do this in my layout of android 我已将Paypal添加到我的Android应用程序中。 我想批准来自商家的付款。 我该怎么做呢? - I have added paypal to my android app. I want to approve the payment from merchant end. How do I do this? 如何在onBindViewHolder中将查询的数据分配给String或int? - How do I assign a queried data to a String or int in onBindViewHolder? 想旋转我的立方体。 我该怎么办 - want to rotate my cube. how could i do that 从通讯录中选择联系人后,如何提取vCard并将其发送? 我要做的就是复制“发送给用户”功能 - Once a contact is selected from address book, how do I extract vCard and send it? All I want to do is to replicate 'Send to User' functionality 我想将XML引入选项卡! 这个怎么做? - I want to introduce XML into tab! how to do this? 我想为搜索创建一个过滤器,我该怎么做,而不会涉及巨大的switch case语句? - i want to create a filter for a search, how can i do this that will not involve a huge switch case statement?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM