A regular expression such as "(Received):" should match every "Received" that precedes a ":".

N++ is finding for me the whole string: "Received:" So instead of highlighting in my document "Received" I am getting "Received:". What's happening? Find and Replace behaves the same.

I am using version 6.5.5 (UNICODE).

  • You are asking it to match Received followed by : (colon) and that is exactly what it is doing. If you want to match just Received then use (Received) not (Received): – DavidPostill Dec 31 '15 at 12:34
  • No, I am asking it to 1) match the word Received 2) only those that precede a colon. ps I don't know why N++ is highlighting the colon also, since it's not in parens. – sasha Dec 31 '15 at 12:36
  • That is what it is matching. The colon is part of the match you asked for. It is not part of the group expression (...) which is intended to be used in the replace with field. – DavidPostill Dec 31 '15 at 12:42
  • 1
    The group expression just stores the match for later. It has nothing to do with highlighting of the whole regular expression match. – DavidPostill Dec 31 '15 at 12:55

RegEx feature you are looking at is a Positive Lookahead. If you search for (Received)(?=:) in:


only 2-nd and 4-th line Received will match.

You have missed a point of () groups a bit.

Grouping by () allows you to capture a characters from inside of a group and use them later.

Try to replace ([\d]+): with prefix_\1_suffix in:


And you should get:

  • "to capture characters ... and use them later". Ok, for extraction. I thought they were the subexpression to be replaced by another. – sasha Dec 31 '15 at 12:54
  • what is "regex future"? – sasha Dec 31 '15 at 12:58
  • "Positive lookahead works just the same. q(?=u) matches a q that is followed by a u, without making the u part of the match. The positive lookahead construct is a pair of parentheses, with the opening parenthesis followed by a question mark and an equals sign." – DavidPostill Dec 31 '15 at 13:12
  • @sasha Groups are subexpressions, but the whole point of it is that you can reference to them later. I mean "feature". – g2mk Dec 31 '15 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.