I'm working with the following vector:

```
vec <- c("[0.81, 1]", "0.00 - 0.03", "0.04 - 0.27",  "0.28 - 0.5",  "0.51 - 0.8")

```

I'm interested in amending the value in the value **"[0.81, 1]"** so it corresponds to the format **number - number**

Working solution
================

Presently I address this requirement in a following manner:

```
vec <- gsub("\\[", "", vec, perl = TRUE)
vec <- gsub("\\]", "", vec, perl = TRUE)
vec <- gsub(",", " - ", vec, fixed = TRUE)

```

The code produces desired requirements:

```
> vec
[1] "0.81 -  1"   "0.00 - 0.03" "0.04 - 0.27" "0.28 - 0.5"  "0.51 - 0.8" 

```

Problem
=======

I would like to achieve my solution using a more complex `gsub` with a more fancy `regex`. I would like to come up with `regex` syntax that would:

* Match first **[** and the last **]** and delete them / replace them with nothing
* Or even better, delete the **[** and **]** and signs and insert the **-** instead of the **,** in the middle. I'm guessing that this may involve making use of `gsubfn` so I'm less keen on this solution

On principle I would like to achieve reduce the number of `gsub` calls.

---

Attempts
========

I tried something like that:

* `\[(?![[:alnum:]])\]` - it doesn't match anything
* `\[(.*)\]` - appears to matching the whole thing

---

What I would like to achieve:

1. Merge first two `gsub` calls into one
2. If possible, merge all 3 calls into one