Reputation: 1393
I have a column with such as Alpha :15s V1
.Beta :15s V2
.Delta :06s V3
. I am trying to use regexreplace
but it won't remove the V
from the string. Here is the formula which I have used so far.
=REGEXREPLACE(T2, "[V]|[V1]-|[V2]|[V3]","")
How do I get this to work where I get the output just as Alpha :15s
Upvotes: 0
Views: 3711
Reputation: 1
you can use this fx:
=ARRAYFORMULA(IFERROR(REGEXEXTRACT(A2:A, "(.*) V")))
which translates as: extract everything (.*)
before space followed by V (.*) V
Upvotes: 1
Reputation: 613
If I get you correctly, you want to remove V1
, V2
and V3
from the end of your text, for which you should use V[123]
regex instead of [V]|[V1]-|[V2]|[V3]
and to be further precise, use \s*V\d*$
regex.
Here \s*
matches any whitespace then matches V
and then matches one or more digits and finally $
matches end of line.
And the reason why it didn't work for you is, when you place characters in square brackets, it is called a character class and match any one character inside square bracket. Hence [V1]
will match either V
or 1
and replace that with empty string which is not what you wanted.
Upvotes: 1