I need to remove some characters from a string. However, there are certain restrictions.
Example phrase:
There are two '@planes' which are almost ' identical in @ how they are built.
I need to find the pattern '@
and the next following '
. Those characters need to be removed from the String. However, if there is only a '
or only a @
they should remain untouched. To clarify, the string can contain one or more words that are enclosed by '@ at the beginning and a single ' at the end. The enclosing characters need to be removed.
After removing the characters it should look like this:
There are two planes which are almost ' identical in @ how they are built.
Another example phrase:
A '@computer' can sometimes be very '@expensive in price' but in other cases it can be @cheap or even free'.
After removing the characters, it should look like this:
A computer can sometimes be very expensive in price but in other cases it can be @cheap or even free'.
The regex should work in JavaScript.