0

I am newbie to regex here's my question:

Below is the content of the file:

cts-pdr/comment-primary/:not spamming
cts-pdr/comment-primary/:please remove since not spamming
cts-pdr/comment-primary/:not spamming
cts-pdr/comment-primary/:not spamming
cts-pdr/comment-primary/:Not spamming
cts-pdr/comment-primary/:not spamming
cts-pdr/comment-primary/:please unblock since not spaming

What I am trying to achieve here is to match the second part of the colon. I'd like to capture the whole string i.e.:

(please\s.*)? [N|n]ot .*

I am not able to get the right match. Can anyone help?

7
  • 3
    No need for regexes here. Split on the colon and take the second part. Commented Dec 27, 2017 at 14:24
  • 1
    Can you please edit your question to have a non-useless title that actually attempts to describe what you're asking? Commented Dec 27, 2017 at 14:27
  • Regex is overkill.This is a simple task using split, as @SergioTulentsev says. Commented Dec 27, 2017 at 14:29
  • @Totem see above for the regex that I've used. I am using regex in unix script. Commented Dec 27, 2017 at 14:30
  • @underscore_d I am trying to match whole string of the second part of the colon. KenWhite like sergio suggested could you please elaborate on how to use the split? Commented Dec 27, 2017 at 14:33

1 Answer 1

1

What you could do is update your regex to:

(please|[N|n]ot).*

And mabye use a non capturing group (?: like:

(?:please|[N|n]ot).*

That would match please or Not or not followed by any character zero or more times .*

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

1 Comment

This worked (?:please|[N|n]ot).* Thanks for the help :)

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.