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: 
If you just want to extract the first digit(s) from your `scan_id` column, you can use `mutate(data, sample = str_extract(scan_id, "[:digit:]+"))` from the `tidyverse`. In this case the first set of digits is extracted.

If you want to specifiy the pattern before your digits, use `mutate(data, sample = str_extract(scan_id, "(?<=[:alpha:]+)[:digit:]+"))`. In this case the first set of digits that is preceded by a set of letters is extracted.
One option would be to use the `stri_extract_first_regex` from `stringi` package

```
library(stringi)
# Extract the one occurance of a digit [0-9]+ ('+' matches 1 or more digits)
df$samples <- stri_extract_first_regex(df$scan_id, "[0-9]+")

```

And the output

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

```

Where `df` is:

```
df <- read.table(text = "scan_id       sample
  s8w_00001.sed      1
  s8w_00001.sed      1
  s9w_00001.sed      1
 s10w_00001.sed      1
 s11d_00002.sed      1
 s12w_00004.sed      1
 s13w_00001.sed      1
 s14w_00001.sed      1", header = TRUE)

```