mercredi 5 octobre 2016

Using Regex in Android Studio can't get the output

i am currently working on an app search button...the button is called srhButton, so once this button is clicked in the search area named (id = query) i would want the variable to check if the (id = query) is in my saved list, and print it out in my Output Ares (id = comment). my problem is my out put won't change

if just say the query is la(la). and if the list contains la(la), it needs to print yes in the comment area

Attached is the code:

srhButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {


            String searchQuery = query.getText().toString();
            String joined = TextUtils.join(",", savedList);
            Pattern ptrn = Pattern.compile("!*\\w*(^[^(]+);\"\\([^(]*?\\).*!;");
            Matcher matcher = ptrn.matcher(searchQuery);
            Matcher matcher1 = ptrn.matcher(joined);
            while (matcher.find()) {
                if (matcher.group(0) == matcher1.group(0)) {
                    comment.setText("YES");
                }
                else
                    comment.setText("invalid number");

                }



            }

Thank you

Aucun commentaire:

Enregistrer un commentaire