Search with both Upper and Lowercase

public class ActivityPS extends AppCompatActivity {
    private PS_DA ps_da = new PS_DA(ActivityPS.this);
    RecyclerView recyclerView;
    android.widget.SearchView searchView;
    Realm realm = Realm.getDefaultInstance();
    AdapterPS adapterPS;
    List<PS> filteredPs;
    RealmResults<PS> psList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ps);
        cast();
        setUpRecycler();
        searchviewSetUp();
    }

    public void searchviewSetUp(){
        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            @Override
            public boolean onQueryTextSubmit(String s) {
                return false;
            }
        });
    }

    @Override
    public boolean onQueryTextChange(String s) {
        filteredPs =filter(psList,s);
        if (filteredPs.size()> 0){
            return true;
        }
        return false;
    }

    public List<PS> filter (List<PS> psLists,String s){
        s = s.toLowerCase();
        filteredPs = new ArrayList<>();
        for (PS psList : psLists){
        final String text = psList.getCommandName().toString().toLowerCase();
        if (text.contains(s));
            filteredPs.add(psList);
        }
        psList = realm.where(PS.class).contains("commandName",s).findAll();
        adapterPS = new AdapterPS(ActivityPS.this,psList,realm);
        recyclerView.setLayoutManager(new LinearLayoutManager(ActivityPS.this));
        recyclerView.setAdapter(adapterPS);

        return filteredPs;
    }
}

I want to search through my realm DB and I want that my search view isn't sensitive with case of letters. I did this but it shows only lowercase data in result whether insert with lowercase or uppercase. I don't know what should I do...

You can make realm DB search case insensitive, add Case.INSENSITIVE boolean as a third argument in the method:

public RealmQuery<E> contains(String fieldName, String value, boolean
> caseSensitive)

From documentation: All four string predicates i.e. contains, beginsWith, endsWith, like have an optional third argument to control case sensitivity: Case.INSENSITIVE and Case.SENSITIVE. The default is Case.SENSITIVE.

psList = realm.where(PS.class).contains("commandName",s, Case.INSENSITIVE).findAll();

How to search a word both uppercase and lowercase given a , How to search a word both uppercase and Learn more about regexp, search, uppercase, lowercase, case MATLAB and Simulink Student  However, sometimes the name is lowercase, e.g. 'bladder'. If one wishes to pull the volume '139.40' from the CSV file, how can one search for both 'Bladder' and 'bladder' in a single query given an input string?

I just Found it.... I change my code to this and it works.

public class ActivityPS extends AppCompatActivity {
private PS_DA ps_da = new PS_DA(ActivityPS.this);
RecyclerView recyclerView;
android.widget.SearchView searchView;
Realm realm = Realm.getDefaultInstance();
AdapterPS adapterPS;
List<PS> filteredPs;
RealmResults<PS> psList;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ps);
    cast();
    setUpRecycler();
    searchviewSetUp();
}

public void searchviewSetUp(){
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {

    return false;
}

@Override
public boolean onQueryTextChange(String s) {

   psList = realm.where(PS.class).contains("commandName",s, Case.INSENSITIVE).findAll();
    adapterPS = new AdapterPS(ActivityPS.this,psList,realm);
    recyclerView.setLayoutManager(new LinearLayoutManager(ActivityPS.this));
    recyclerView.setAdapter(adapterPS);


    return false;
}

That .Case.INSENSITIVE did that automatically.

Python regex to find sequences of one upper case letter followed by , Write a Python Program to find sequences of one upper case letter followed by lower case letters. If found, print 'Yes', otherwise 'No'. Examples: Input : Geeks  Again, the trick is to convert whatever you’re searching for to uppercase or lowercase using the SQL upper and lower functions, and then make your search string match that case.

Make all the results .to lower case, thus what ever u rnter will not be sensitive.

Check if lowercase and uppercase characters are in same order , Store the lowercase alphabets and uppercase alphabets in two separate strings lowerStr and upperStr respectively. Convert lowercase string to uppercase. Check  Similar to fetching the lower case string, we can search for upper case string just by changing the LOWER string function to UPPER string function. See the example below. Fetching only the rows having all uppercase in one of the column using COLLATE method. 1

toLowerCase and toUpperCase, Takes a string and converts it to all lower case or upper case letters. _sourceCategory=service OR _sourceCategory=search All upper case letters are converted to lower case and all lower case letters are converted to upper case. The tOGGLE cASE text tool comes in handy for when text has been written in upper case due to the Caps Lock key being left on inadvertently. Instead of deleting the affected text, they can be highlighted and converted to lower case letters.

Upper Case & Lower Case Searches May Return Different Google , Upper Case & Lower Case Searches May Return Different Google so please document your findings both here and at the thread so we can  Upper case is often used by trademark practitioners to identify a trademark. Otherwise, if the same mark exists as an active mark on the register at the PTO, filing for a lower case mark in the same class of goods/services will make no difference and will be refused over the prior word mark identified in upper case.

What is Uppercase? Webopedia Definition, For example, box is in lowercase while BOX is in uppercase. The term is a vestige of the days when typesetters kept capital letters in a box above the lowercase  In the menu bar, on the Home tab, click the Change Case icon, which has an uppercase 'A' and lowercase 'a.' Select the appropriate option from the list of values. For example, if you want to change to all uppercase letters, select the UPPERCASE option. If you want to change to all lowercase letters, select the lowercase option.

Comments
  • I have never worked with Realm, but one general piece of advice I can give you is that if you have the need to do case insensitive searches, then consider just storing all data in lowercase form, and then also searching using lowercase inputs.
  • if I store them with .toLowercase mode when i want to show `em with recycler view, it show with lowercase? @TimBiegeleisen
  • yes that work. thank you very much.although I find that my self but thank you