Textpad tricks Find and replace Input : 66 Urology & Nephrology 737 Spermatogenesis Replace : the bold text in the above input Find Pattern : ^\([0-9]+\)\(.*[a-z \t]+\)\([0-9]+\) Replace pattern: \1 \3 output: 66 737 Spermatogenesis Gotcha's Always escape group by characters ( or ) with \ [backslash] like this \( \) ^ is the beginning of the line $ is the end of the line \n is new line.
Friday, August 1, 2008
Textpad tricks
Subscribe to:
Post Comments (Atom)
1 comment:
CSV Editing:
Remove spaces and tab characters at the beginning of a line:
Find what: ^[ \t]+
Replace With: don't enter anything in the field
Remove spaces and tab characters at the end of a line:
Find what: [ \t]+$
Replace With: don't enter anything in the field
Add “Hello” to the beginning of every line:
Find what: \(^.*\)
Replace With: Hello \1
Add “Hello ” to the beginning and ” World” to the end of every line:
Find what: \(^.*\)
Replace With: Hello \1 World (watch the spaces)
Find empty fields (i.e. “, ,”) with spaces or tabs in, and replace with empty field (”,,”):
Find what: ,[ \t*],
Replace With: ,, (just that, nothing else, just 2 commas)
Remove blank lines in a text file, by searching for two linebreaks next to each other, and replacing with one:
Find what: \n\n
Replace With: \n
Replacement Expressions:
Extract email addresses only from the following text: “Joe Blogs (job.blogs@blogsworld.com)”
This expression searches for 2 tagged expressions, firstly any printable characters including spaces up to the first open bracket symbol, secondly anything between the brackets. It then replaces the whole line with the second match.
Find what: ^\([[:graph:] ]+\)(\([[:graph:] ]+\))
Replace With: \2
Reference: http://www.myquickfix.co.uk/index.php/2008/12/textpad-regular-expressions/
Post a Comment