0

I have series of line in following format:

               LINE:  5190 STNO:  22669  SI: VOICE
          CCT   LINE    STNO  SI    BUS TYPE
          003   6269                OPTI ONLY     
           MULTLINE 8. . . . . . . . . . . . . . .
           001 SUBUNIT . . . . . DIGITE MAIN      DEFIL/TRS
           (ALT_ROUT: N)       (OPTIIP  )
               LINE:  5291 STNO:  29956  SI: VOICE

What I need to find through regex (notepad++) are the numbers just after "STNO:"

There are approximately 100 of such matches.

I tired STNO:\s+\d{4,5} but it is taking STNO also into the match which i do not want. Please help.

I need to keep the matched result only and rest i want to delete or copy the matched items to a new file whichever is easier.

4

1 回答 1

1

我建议采用两步法。首先获取带有 STNO 和数字的所有行。其次删除除数字之外的所有内容。

在查找对话框中选择标记选项卡。确保书签行被勾选。在Find what框中输入STNO:\s*\d+,然后单击Mark all

访问菜单 => 搜索 => 书签 => 复制书签行。然后粘贴到另一个缓冲区。或者,要在同一个文件中工作,请使用 Menu => Search => Bookmark => Remove unmarked lines。现在您应该将所有想要的行都放在缓冲区中。

执行正则表达式搜索和替换设置Find what to be^.*STNO:\s*(\d+).*$Replace with to \1。然后单击全部替换

以上假设每行只能找到一个数字。

==========================

由于只需要数字,另一种方法是在所需数字周围放置换行符和标记,然后删除没有标记的所有行,最后删除标记。

让标记为keep。进行搜索和替换设置Find what to bekeepReplace with到单个空格字符,确保未选择Match case ;然后点击全部替换。接下来,进行正则表达式搜索和替换设置Find what to be^STNO:\s*(\d+)Replace with to \r\nkeep\1\r\n。您可能希望匹配大小写;然后点击全部替换接下来用Find what set to标记行(如上所述)keep,然后是 Menu => Search => Bookmark => Remove unmarked lines。最后,做一个搜索和替换设置Find what to bekeep替换为空。

于 2013-07-19T14:55:48.300 回答