0

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

2 Answers 2

1

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.

enter image description here

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.

Sign up to request clarification or add additional context in comments.

Comments

1

you can use this fx:

=ARRAYFORMULA(IFERROR(REGEXEXTRACT(A2:A, "(.*) V")))

0

which translates as: extract everything (.*) before space followed by V (.*) V

2 Comments

What if there is no pattern at all to the strings that you want to remove (no pattern in their character count, position in the parent string, etc..) and you want to target them specifically listing them out? So in the above example, what if you wanted to omit just the words "Alpha" and ":06s"?
@ShianHan then it would be: =ARRAYFORMULA(IFERROR(REGEXREPLACE(A2:A, "Alpha|:06s", )))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.