Question: This is my editText:

```
      <EditText
                android:id="@+id/max_deep_bin"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:digits="0123456789"
                android:foregroundGravity="center"
                android:singleLine="true"
                android:gravity="center"
                android:inputType="numberDecimal"
                android:text="@string/zero"
                android:textSize="60sp"
                android:textStyle="bold" />

```

This edittext have to be in one line so I put a parameter : `android:singleLine="true"` but when a text is too long I want to change a textSize how I can do this ?

Answer: 
You can use `gsub`, i.e

```
gsub('s([0-9]+)[a-z]+_.*$', '\\1', df$scan_id)
#[1] "8"  "8"  "9"  "10" "11" "12" "13" "14"

```
You can also do:

```
df$sample <- gsub("\\D", "", sapply(strsplit(df$scan_id, "_"), function(x) x[1]))

         scan_id sample
1  s8w_00001.sed      8
2  s8w_00001.sed      8
3  s9w_00001.sed      9
4 s10w_00001.sed     10
5 s11d_00002.sed     11
6 s12w_00004.sed     12
7 s13w_00001.sed     13
8 s14w_00001.sed     14

```

Here it splits the "scan\_id" on `_` and then extracts the numbers from the first element after split.