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

grep Filter lines matching a pattern

Aa Text
Input0 chars
Output0 chars

Flags

--pattern string default:
--invert boolean default: false
--caseSensitive boolean default: false

Examples

Filter log lines matching ERROR

Usage
"INFO: started
ERROR: disk full
INFO: request ok
ERROR: timeo..." | grep --pattern=ERROR

Find all lines containing a specific product name

Usage
"Widget Pro - $29.99
Gadget Plus - $49.99
Widget Basic - $9.9..." | grep --pattern=Widget

Extract lines with phone numbers from meeting notes

Usage
"Call John at 555-1234
Email: [email protected]
Fax is obsolete
C..." | grep --pattern=555
View source
(input, opts = {})=>{
                if (!opts.pattern) return input;
                try {
                    const flags = opts.caseSensitive ? "" : "i";
                    const re = new RegExp(opts.pattern, flags);
                    return input.split("\n").filter((l)=>(opts.invert ? !re.test(l) : re.test(l))).join("\n");
                } catch  {
                    return `Error: invalid regex "${opts.pattern}"`;
                }
            }