Search code examples
regexnotepad++

Notepad++ Regex help - Finding less than 6 chars in quotations


How would I go about creating a regex search to find numbers less than X characters long within quotes? Less than 6 chars in the following example:

"+3256974589654" <- Not this
"+5256974584654" <- Not this
"+6256974553654" <- Not this
"43567" <- This
"98765" <- This

EDIT
Just found this: Unsupported operators in Notepad++/Scintilla regular expression syntax

Looks like something similar to [0-9]{1,5} will not work as {m,n} (where m and n are integers) are not supported.

EDIT
The regex I used was "[0-9]{0,10}". Sadly Notepad++ does not support {x,y} therefore I ended up using a free editor called "Programmer's Notepad".


Solution

  • Since Notepad++ (apparently) doesn't support X{m,n} syntax, you could work around it by m X followed by n-m X?. So for [0-9]{1,5} you could instead use:

    [0-9][0-9]?[0-9]?[0-9]?[0-9]?
    

    Not the prettiest/fastest, but it should work. (Note that [0-9] can be replaced by \d)

    (Make sure you are using the latest version of Notepad++, as ? support was included in version 5.9)