You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何删除Notepad++以外的所有内容?提取userId附近的ID

Hey there! Let's tackle your two Notepad++ tasks step by step—super straightforward once you know the regex tricks.

1. Delete everything except your target content in Notepad++

The easiest way to strip out unwanted content is using regular expression replace. Here's how:

  • Hit Ctrl+H to open the Replace window.
  • Switch to the "Regular expression" mode (make sure "Wrap around" is checked; tick "Match newline" if you need to target content across lines).
  • Example scenario: If you only want to keep lines that mention "userId", use this setup:
    • Find what: ^(?!.*userId).*$\r?\n?
    • Replace with: (leave this blank)
    • Click "Replace All"—boom, all lines without "userId" are instantly removed.
  • If you need to preserve a specific format (like all id: XXX entries), adjust the regex to target your desired content, or use the "Find All in Current Document" feature: search for your target pattern, right-click the matches, select "Copy All", then paste into a new clean document.
2. Extract only IDs near "userId" and format them

Since you didn't share the exact required output style, I'll give you a flexible regex method you can tweak to fit your needs:
First, identify how your userId is formatted (e.g., "userId": "12345", userId=abc789, etc.). Let's walk through two common cases:

Case 1: JSON-style "userId": "12345"

  • Open Replace (Ctrl+H) → Regular expression mode.
  • Find what: .*"userId": "(\d+)".*
  • Replace with: $1 (or your desired format, like User ID: $1 if you need labels for each entry)
  • Click "Replace All", then go to Edit > Line Operations > Remove Empty Lines to clean up leftover blank rows.

Case 2: Plain text userId=abc789 (alphanumeric IDs)

  • Find what: .*userId=(\w+).*
  • Replace with: $1 (or your custom style)
  • Run the same empty line cleanup step as above to tidy the result.

If you need to keep a bit of context around the userId (like the line before/after), use a multi-line regex. For example, to keep the userId line plus the line immediately after:

  • Find what: .*userId.*\r?\n.*\r?\n?
  • Replace with: $0 (this retains the matched content)
  • Then remove any remaining empty lines to polish the final output.

内容的提问来源于stack exchange,提问作者Mostafa A alsharqawy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:28:37