Alex
Alex

Reputation: 3968

Notepad++ regex searching

I want to search a document with Notepad++ for the following text:

A

eg. a space then a capital A then a space.

I have the following RegExp to do it:

\s[A-A]\s?

Which almost does it, except it will highlight all the spaces after the A, rather than just the first one, which is not what I want.

From what I understand, the ? after the regex means it should not be doing this?
So maybe it is Notepad that is highlighting this text?

Any ideas what I am doing wrong?

Upvotes: 2

Views: 116

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626758

You can use a positive look-ahead (?=\s?) so that if there is a space after "A" it was not included in the match:

\sA(?=\s?)

Also, [A-A] is in fact just A.

Upvotes: 4

Related Questions