pipr.tools
Pipes
Clean Email Strip formatting from pasted email for clean plain text Clean AI Output Clean plain text from ChatGPT or AI output Decode & Format JWT Decode a JWT and pretty-print header and payload Word Frequency Count word frequency in text

regex-extract Extract all matches of a regex pattern

.* Regex
Input0 chars
Output0 chars

Flags

--pattern string default:

Examples

Extract phone numbers from text

Usage
"Call 555-1234 or 555-5678
Fax: 555-0000" | regex-extract --pattern=\d{3}-\d{4}

Extract hashtags from social media posts

Usage
"Trending now: #SummerSale #BigSavings #ShopNow
Check out #Ne..." | regex-extract --pattern=#\w+

Pull all dates from meeting notes

Usage
"Meeting on 2025-06-15, follow-up by 2025-06-22.
Deadline: 20..." | regex-extract --pattern=\d{4}-\d{2}-\d{2}
View source
(input, opts = {})=>{
                if (!opts.pattern) return "Error: provide --pattern";
                try {
                    const re = new RegExp(opts.pattern, "gm");
                    const matches = [
                        ...input.matchAll(re)
                    ];
                    if (!matches.length) return "(no matches)";
                    return matches.map((m, i)=>`${i + 1}: ${m[0]}${m.length > 1 ? `  →  groups: [${m.slice(1).join(", ")}]` : ""}`).join("\n");
                } catch (e) {
                    return `Error: ${e.message}`;
                }
            }

Related Tools