I needed to do some text manipulation (reformat sample names) in R and it suddenly hit me that I can use regex capturing groups and write a on-liner. I was surprised that the default `base::gsub()` actually handled them without any issues:
```r
gsub(x = "Sample1_blah_Treatment2",
pattern = "^([\\w])\\w+(\\d+)_[^_]+_([\\w])\\w+(\\d+)",
replacement = "\\1\\2.\\3\\4",
perl = T)
```
> [1] "S1.T2"
My days of using Perl and learning regex is paying off 😅







