Search code examples
notepad++

Notepad ++ how to search for specific spaces?


I have a text in a Notepad++ that has specific amount of spaces.

  "revision": ,
  "checking": {
    "startcount": {
      "dateCreated": "20230101",
      "definitions": {
        "Gamesplayed": {
          "community": false,

I would like to select all the lines that have exactly 12 spaces. In this case, this would be:

Gamesplayed

Is there a way to do this?


Solution

  • You can use the following regular expression to search for the lines that have exactly 12 spaces

    ^\s{12}"(\w+)":\s{
    

    Example on Regex101

    Explanation:

    • ^ - Denotes the start of the line
    • \s - Matches whitespace character
    • {12} - Matches the previous token exactly 12 times
    • " - Literal quote
    • (\w+) - Capture group capturing any word
    • " - Literal quote
    • : - Literal colon
    • \s - Matches on space
    • { - Literal curly left brace

    You could also shorten the regex using

    ^\s{12}(.*)
    

    Where (.*) will just capture everything