Question: My xml code is :

```
<Spinner
    android:id="@+id/destination"
    android:layout_width="344dp"
    android:layout_height="30dp"
    android:autofillHints="Choose destination"
    android:spinnerMode="dropdown" />

```

I want to add hint (without using dummy entry) as to be shown to user when the activity starts.
The inbuilt xml hint feature is not working after using FireBase.

MainActivity :

```
myRef.child("Stations").addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            final List<String> stationname = new ArrayList<String>();

            for (DataSnapshot stationSnapshot : dataSnapshot.getChildren()) {

                 String stationName = stationSnapshot.child("Name").getValue(String.class);
                 stationname.add(stationName);
            }

            Spinner sp2= findViewById(R.id.destination);

            ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(FairPage.this, android.R.layout.simple_spinner_item, stationname);
            arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

            sp2.setAdapter(arrayAdapter);

```

Answer: 
Are you sure you need a regex ?
Something like this can calculate the ratio in a row :

```
>>> a = list('abce')
>>> b = list('abcd')
( 100 - (sum(i != j for i, j in zip(key, 'air')) / float(len(a))) * 100 )
75.0

```

But if `b = list('bdce')` it will just be 50%
This approach uses n-grams to allow for varying ratios and varying lengths of the key, while simultaneously ensuring that the letters must be continuous.

```
import re
import math

key = 'paint'
n = math.ceil(len(key) * 0.75) # use ceiling for when len(key) * 3 is not a factor of 4

def ngrams(key, n):
    output = []
    for i in range(len(key) - n + 1):
        output.append(key[i:(i+n)])
    return output

patterns = '|'.join(ngrams(key, n))
regex = r'^[a-z0-9_]*' + patterns + '[a-z0-9_]*$'

print("Allowed matches: {}".format(patterns))
print("Pants matches: {}".format(bool(re.search(regex, 'pants'))))
print("Pains matches: {}".format(bool(re.search(regex, 'pains'))))
print("Taint matches: {}".format(bool(re.search(regex, 'taint'))))

Allowed matches: pain|aint
Pants matches: False
Pains matches: True
Taint matches: True

```

Keep in mind, that Python already has a method for checking for substrings using the `in` key word with two strings. So you can skip the regex and do this:

```
patterns = ngrams(key, n)
for test in ['pants', 'pains', 'taint']:
    matches = 0
    for pattern in patterns:
        if pattern in test:
            matches += 1
    if matches:
        print(test, 'matches')
    else:
        print(test, 'did not match')

pants did not match
pains matches
taint matches

```