<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>My Quick Fix &#187; Textpad</title>
	<atom:link href="http://myquickfix.co.uk/index.php/category/computers/web-development/tools/textpad-tools-web-development-computers/feed/" rel="self" type="application/rss+xml" />
	<link>http://myquickfix.co.uk</link>
	<description>Quick fixes for niggly problems...</description>
	<lastBuildDate>Thu, 24 Sep 2009 15:10:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Textpad Regular Expressions</title>
		<link>http://myquickfix.co.uk/index.php/2008/12/textpad-regular-expressions/</link>
		<comments>http://myquickfix.co.uk/index.php/2008/12/textpad-regular-expressions/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 13:31:40 +0000</pubDate>
		<dc:creator>hutch</dc:creator>
				<category><![CDATA[Textpad]]></category>
		<category><![CDATA[regular expressions]]></category>

		<guid isPermaLink="false">http://www.myquickfix.co.uk/?p=77</guid>
		<description><![CDATA[Textpad is a great editor, been using it for years, but never really used it to it&#8217;s full potential. Recently I needed to do some find/replace work in some huge SQL and CSV files &#8211; huge enough to make manual editing impossible &#8211; so I had to start using Textpad&#8217;s Regular Expression capabilities.
Here are a few expressions that came in handy. I intend to add to this list as time goes on.
Regexp shown in Green, my comments in Red.
CSV Editing:
Remove spaces and tab characters at the beginning of a line:
Find ...]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.textpad.com/">Textpad</a> is a great editor, been using it for years, but never really used it to it&#8217;s full potential. Recently I needed to do some find/replace work in some huge SQL and CSV files &#8211; huge enough to make manual editing impossible &#8211; so I had to start using Textpad&#8217;s Regular Expression capabilities.</p>
<p>Here are a few expressions that came in handy. I intend to add to this list as time goes on.<br />
Regexp shown in <span style="color: #008000;">Green</span>, my comments in <span style="color: #cc0000;">Red</span>.</p>
<p><strong>CSV Editing:</strong></p>
<p>Remove spaces and tab characters at the <em>beginning</em> of a line:<br />
<code>Find what: <span style="color: #008000;">^[ \t]+</span><br />
Replace With: <span style="color: #cc0000;">don't enter anything in the field</span></code><br />
Remove spaces and tab characters at the <em>end</em> of a line:<br />
<code>Find what: <span style="color: #008000;">[ \t]+$</span><br />
Replace With: <span style="color: #cc0000;">don't enter anything in the field</span></code><br />
Add &#8220;Hello&#8221; to the <em>beginning</em> of every line:<br />
<code>Find what: <span style="color: #008000;">\(^.*\)</span><br />
Replace With: <span style="color: #008000;">Hello \1</span></code><br />
Add &#8220;Hello &#8221; to the <em>beginning</em> and &#8221; World&#8221; to the <em>end</em> of every line:<br />
<code>Find what: <span style="color: #008000;">\(^.*\)</span><br />
Replace With: <span style="color: #008000;">Hello \1 World</span> <span style="color: #cc0000;">(watch the spaces)</span></code><br />
Find empty fields (i.e. &#8220;, ,&#8221;) with spaces or tabs in, and replace with empty field (&#8220;,,&#8221;):<br />
<code>Find what: <span style="color: #008000;">,[ \t*],</span><br />
Replace With: <span style="color: #008000;">,,</span> <span style="color: #cc0000;">(just that, nothing else, just 2 commas)</span></code><br />
Remove blank lines in a text file, by searching for two linebreaks next to each other, and replacing with one:<br />
<code>Find what: <span style="color: #008000;">\n\n</span><br />
Replace With: <span style="color: #008000;">\n</span></code></p>
<p> </p>
<p><strong>Replacement Expressions:</strong></p>
<p>Extract email addresses only from the following text: &#8220;Joe Blogs (job.blogs@blogsworld.com)&#8221;<br />
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.<br />
<code>Find what: <span style="color: #008000;">^\([[:graph:] ]+\)(\([[:graph:] ]+\))</span><br />
Replace With: <span style="color: #008000;">\2</span></code></p>
<p> </p>
<p><strong>Notes:</strong></p>
<ul>
<li>The expressions above need the &#8216;Regular Expression&#8217; condition to be ticked in the Find or Replace dialogue boxes for them to work.</li>
<li>Text pad needs to be set to use UNIX not POSIX style expressions. To set this, open &#8216;Configure &gt; Preferences&#8217; (Ctrl+Q,P), find the &#8216;Editor&#8217; settings, and untick the &#8216;Use POSIX regular expression syntax&#8217; box.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://myquickfix.co.uk/index.php/2008/12/textpad-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
