Regex - remove element

Asked

Viewed 179 times

0

I want to delete all characters except the last 3 letters that are uppercase. And another thing, like I do several regex together?

  • The theory of this question is relevant: https://answall.com/q/241285/64969 so you will know how to join regular expressions (mathematical flavor), and also how to compose what you need

  • Could you explain better what you want to do? As well put several regex together?

  • Could complement with an example to avoid possible misinterpretations?

  • This can be done using Wildcards also, using a Like Operator

1 answer

0

The syntax depends on the regex implementation you are using. But an example using the js syntax:

str.replace(/^.*([A-Z])[^A-Z]*([A-Z])[^A-Z]*([A-Z])[^A-Z]*$/, '$1$2$3')
  • I think the parentheses within the group are wrong. I also believe that you wanted to put the quantifier 3 times after the parentheses, grouping uppercase letters etc. And I also believe that here you did not isolate the uppercase letters, I understood that the answer should return only the last 3 uppercase letters

  • 1

    This gives write code on mobile (and without testing) :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.