Author: Andrew Kingdom Note: These are grep patterns I find useful for the BBEdit text editor on MacOS. Some templates may need modification/changes before use on your specific data.
-
Remove Blank Lines
- Find:
^\s*$\n - Replace: (empty string)
- Find:
-
Pascal Comment to C Comment
- Find:
{([^}]*)} - Replace:
/* \1 */
- Find:
-
C++ Comment to C Comment
- Find:
//(.*) - Replace:
/* \1 */
- Find:
-
Run of Spaces to One Tab
- Find:
+ - Replace:
\t
- Find:
-
C Function Header
- Find:
^[^ \t#\n/@][^\n]*\([^\n]*\)$ - Replace: (empty string)
- Find:
-
C Comment to Pascal Comment
- Find:
/\*([^\n]*)\*/ - Replace:
{ \1 }
- Find:
-
Shift Variables Right
- Find:
(.*)(\t\t*)(.*) - Replace:
\1\2\t\3
- Find:
-
Shift Variables Left
- Find:
(.*)(\t)(\t*)(.*) - Replace:
\1\3\4
- Find:
-
Lower Case SRC values in IMG tags
- Find:
(<img [^>]*src\s*=\s*")([^"]+)("[^>]*>) - Replace:
\1\L\2\E\3
- Find:
-
Lower Case HREF values in A tags
- Find:
(<a [^>]*href\s*=\s*")([^"]+)("[^>]*>) - Replace:
\1\L\2\E\3
- Find:
-
Column #2
- Find:
^[^\t]+\t([^\t]+) - Replace:
\1
- Find:
-
Dotted Quad
- Find:
(\d+\.){3}\d+ - Replace:
foo bar
- Find:
-
Xcode Logs: Strip Prefix — requires the newlines versus \n
- Find: `2022-02-15 13:\d\d:\d\d.\d\d\d\d\d\d+1100 [A-Za-z]*
[\d*:\d*] `
-
Replace: (empty string)
-
Xcode Logs: Strip Context
- Find:
Context@0x[0-9A-F]*: ............ \d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d.\d\d\d - Replace: (empty string)
- Find:
-
BBEdit Find: Remove Path
- Find:
.*:\d*:\s(.*) - Replace:
\1
- Find:
-
Xcode Find: Remove Time and Process — requires the newlines versus \n
- Find: `.*]
\s*(.*)`
-
Replace:
\1 -
List to Objective-C Dictionary
- Find:
(.*)\r - Replace:
@"\1" : \1,\r
- Find:
-
Replace 2 or More Spaces with Tab
- Find:
\s\s\s* - Replace:
\t
- Find:
-
JavaScript Object Function to Plain Function
- Find:
(\s*)([a-zA-Z_]*):\sfunction\s*(\(.*\))(\s*) - Replace:
\1function \2 \3\4
- Find:
-
Split Delimited Text into Two Columns
- Find:
([^\|]*)\|([^\|]*)\| - Replace:
\1\t\2\r
- Find:
-
Extract "prompt": "..."
- Find:
"prompt":"(.*?(?:\\.|[^"])*)" - Replace:
\1\r—\r
- Find:
-
Find Mid-Prompt Monsters
- Find:
^.* monster .*$\r—\r - Replace: (empty string)
- Find:
-
Remove
//Comments- Find:
//.*$ - Replace: (empty string)
- Find:
-
Remove Blank Line Whitespace
- Find:
\r[\s\t]*$ - Replace: (empty string)
- Find:
-
Extract
<img>Elements- Find:
<img id="([^"]*)" .*src="([^"]*)" .*alt="([^"]*)".*> - Replace:
{"title":"\1","path":"\2","description":"\3"},
- Find:
-
2× Leading Spaces → Tabs (Repeat Until None Found)
- Find:
^(\t*)( {2}) - Replace:
\1\t
- Find: