最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

regex - how to select the number which has only 12 digits in notepad++ - Stack Overflow

programmeradmin3浏览0评论

how to select the number which has only 12 digits in notepad++

Input:
240018872152
14020730282717905547520
15790317091114502905425
15790317091194502905429
15790317091164502905427

Output:
240018872152

how to select the number which has only 12 digits in notepad++

Input:
240018872152
14020730282717905547520
15790317091114502905425
15790317091194502905429
15790317091164502905427

Output:
240018872152
Share Improve this question edited Mar 23 at 9:51 bobble bubble 18.7k4 gold badges31 silver badges50 bronze badges asked Mar 16 at 19:08 Barath TMBarath TM 13 1
  • Related: Regular expression to match exactly 5 digits – bobble bubble Commented Apr 6 at 8:33
Add a comment  | 

3 Answers 3

Reset to default 2

Based on this answer, it seems that Notepad++ supports regex.
In that case, I would look for the regex \b\d{12}\b.

Use negative lookaround:

(?<!\d)\d{12}(?!\d)

This is matching 12 digit number \d{12} not preceeded by digit (?<!\d) and not folowed by digit (?!\d)

\d{12} will find a string of 12 digits, but tht will include a string of 12 digits contained within a longer string, so we need to constrain it.

In normal operation, NP** searches line by line, and your sample data above shows the 12-digit string alone on a line, so we can anchor the search points at the beginning and end of a line with ^ and $ respectively.

Thus, search for ^\d{12}$. To locate all the 12-digit strings click the Find All... button.

For example

Input:

240018872152
14020730282717905547520
157903170911
15790317091194502905429
15790317091164502905427

Output:

Search "^\d{12}$" (2 hits in 1 file of 1 searched)
  new 1 (2 hits)
    Line 1: 240018872152
    Line 3: 157903170911
发布评论

评论列表(0)

  1. 暂无评论