0

I want to get rid of texts like "uc010obu.2:" in each line. I tried to write the following, but the pattern is not recognizable.

%s/uc(\d\+)(\w\+).(\d\+)://

Could someone help with the right pattern? thanks

each line is something like this:

CPEB2 uc010obu.2:c.1070_1071insCGG:p.G357delinsGG

ps: I am trying to do in vim editor.

3
  • 1
    Can you also give us the text you are trying to perform the regexp on? it gives us something to reference and test on. Commented Sep 17, 2014 at 19:46
  • Is that being used as an argument to sed? vim? Something else? Why are you grouping those matches if you are throwing it all away? Commented Sep 17, 2014 at 19:47
  • Is the text you are removing always two letters followed by three numbers three letters a period a number and ends with a colon? Commented Sep 17, 2014 at 19:51

3 Answers 3

1

do not group your regex.

:%s/uc\d\+\w\+\.\d\+://

if you want to group, use \( and \) instead. if you are using perl-compatible tool, it's ( and ).

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

Comments

1

You can use this regex in vim/sed:

%s/uc\d\+\w\+\.\d\+://

Or else:

g/uc\d\+\w\+\.\d\+:/d

2 Comments

but uc010obu.2 can be ucxxxxxx.x
Sorry, bad copy/paste fixed now.
1

If you want to match text with only the varying numbers you can try this pattern:

uc(\d+)(\w+).(\d+):

To try, you can use the website http://rubular.com/

Comments

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.