Counting characters in a string in notepad ++

I try to count the number of times a character appears on one line, and then edits the lines that it makes.

Let's say I have a line that goes:

\serv\file\subfile\subsubfile\subsubsubfile

Is it possible to count the number of times a symbol appears \, and if it no longer appears twice, clear the line and leave it blank?

+3
source share
3 answers

to find ^([^\\]*[\\]?[^\\]*){0,2}$

replace with empty string

+4
source

Is that what you want to do?

To find - ^(?!.*\\.*\\.*\\.*).*$\r\n

Replace -

enter image description here

When you execute Replace All, you will also get the number of rows that have been replaced - you will get a counter

In my example, the 2nd, 4th and 5th lines will be deleted, since they have less than 2 slashes ()

+2

:

^[^\\]*\\[^\\](?:*\\[^\\]*)?$

. : http://regex101.com/r/qW0jE3

\, :

  • (?:*\\[^\\]*) .
  • Change the second number in a regular expression: ^(?:[^\\]*\\[^\\]*){0,2}$.
  • Change the first number in a regular expression: ^(?:\\?[^\\]*){2}$.
+1
source

All Articles