<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Using Grep within BBedit to change some data in tables.</title>
	<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables/</link>
	<description>Comments on Ask MetaFilter post Using Grep within BBedit to change some data in tables.</description>
	<pubDate>Thu, 06 Jan 2005 15:18:07 -0800</pubDate>
	<lastBuildDate>Thu, 06 Jan 2005 15:18:07 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Using Grep within BBedit to change some data in tables.</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables</link>	
		<description>I&apos;m using Grep within BBedit 6.1.2 lite, in order to change some data in tables from &quot;regular&quot; time in the format: &quot;0530PM&quot;  to military time: &quot;1730&quot;&lt;br&gt;
&lt;br&gt;
Essentially, I am able to locate the data I want using:&lt;br&gt;
&lt;br&gt;
(####)PM&lt;br&gt;
&lt;br&gt;
Which, in the above example returns: &quot;0530&quot;&lt;br&gt;
&lt;br&gt;
So here&apos;s the question: I want to treat that result as a number, and add 1200 to it to convert it to military time.  &lt;br&gt;
&lt;br&gt;
Is there a way to do this within BBedit using the replacement patterns, or do I have to go figure out how to write a perl/python/awk/applescript to accomplish this?</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2005:site.13714</guid>
		<pubDate>Thu, 06 Jan 2005 15:00:21 -0800</pubDate>
		<dc:creator>mecran01</dc:creator>
		
			<category>bbedit</category>
		
			<category>grep</category>
		
			<category>applescript</category>
		
			<category>awk</category>
		
			<category>python</category>
		
			<category>perl</category>
		
	</item> <item>
		<title>By: dorian</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables#236777</link>	
		<description>my regexp skill is not so great doing conditional results so here is a terrible terrible lazy way...&lt;br&gt;
you could do 12 separate replaces on your set of files, along the lines of:&lt;br&gt;
&lt;br&gt;
replace: (05)(\d\d)PM&lt;br&gt;
with: 17\2&lt;br&gt;
&lt;br&gt;
replace: (01)(\d\d)PM&lt;br&gt;
with: 13\2&lt;br&gt;
&lt;br&gt;
etc. (my bbedit seems to like \d instead of #, but same idea)&lt;br&gt;
&lt;br&gt;
personally I would use perl or applescript+bbedit if it&apos;s more than just a one-time thing.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.13714-236777</guid>
		<pubDate>Thu, 06 Jan 2005 15:18:07 -0800</pubDate>
		<dc:creator>dorian</dc:creator>
	</item><item>
		<title>By: neustile</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables#236778</link>	
		<description>not easily, I made a one minute (very bad code but works) perl script though. save it to &quot;whatever.pl&quot; and run it in terminal like &quot;perl whatever.pl &lt; inputfile&gt; outputfile&quot;&lt;br&gt;
&lt;br&gt;
while(&lt;&gt;) {&lt;br&gt;
   while(/([0-9]{4})PM/) {&lt;br&gt;
      $mil = int($1)+1200;&lt;br&gt;
      $str = &quot;$1&quot;. &quot;PM&quot;;&lt;br&gt;
      s/$str/$mil/;&lt;br&gt;
   }&lt;br&gt;
   print;&lt;br&gt;
}&lt;/&gt;&lt;/&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.13714-236778</guid>
		<pubDate>Thu, 06 Jan 2005 15:20:05 -0800</pubDate>
		<dc:creator>neustile</dc:creator>
	</item><item>
		<title>By: mecran01</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables#236786</link>	
		<description>Thanks very much.  I will study your sample code after running it and hopefully learn something.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.13714-236786</guid>
		<pubDate>Thu, 06 Jan 2005 15:34:47 -0800</pubDate>
		<dc:creator>mecran01</dc:creator>
	</item><item>
		<title>By: Zed_Lopez</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables#236789</link>	
		<description>perl -pi.bak -e &apos;s/(\d{4})PM/($1+1200)/e&apos;  filename&lt;br&gt;
&lt;br&gt;
Makes a backup of the original in filename.bak while it&apos;s at it, too.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.13714-236789</guid>
		<pubDate>Thu, 06 Jan 2005 15:42:26 -0800</pubDate>
		<dc:creator>Zed_Lopez</dc:creator>
	</item><item>
		<title>By: AlexReynolds</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables#236810</link>	
		<description>BBEdit Lite is not scriptable. You won&apos;t be able to use AppleScript, Python, etc.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.13714-236810</guid>
		<pubDate>Thu, 06 Jan 2005 16:34:30 -0800</pubDate>
		<dc:creator>AlexReynolds</dc:creator>
	</item><item>
		<title>By: mecran01</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables#236811</link>	
		<description>&lt;i&gt;perl -pi.bak -e &apos;s/(\d{4})PM/($1+1200)/e&apos; filename&lt;/i&gt;&lt;br&gt;
&lt;br&gt;
I&apos;ve been trying this slick single-line solution, but have hit some probs.&lt;br&gt;
&lt;br&gt;
Something in the replace string appears to be el kabong.  I can get it working if I remove the .bak extension, and try other replacements:&lt;br&gt;
&lt;br&gt;
perl -pi -e &apos;s/(\d{4})PM/cheese/e&apos; filename&lt;br&gt;
&lt;br&gt;
works, for example.  I have to run it twice, because the original data is in the form of&lt;br&gt;
&lt;br&gt;
,0530PM-0730PM, &lt;br&gt;
&lt;br&gt;
Anyway, you&apos;ve given me the basic syntax so now I guess it&apos;s time to start reading that copy of &quot;Mastering Regular Expressions&quot; I bought a few years ago.&lt;br&gt;
&lt;br&gt;
Oh, I&apos;m running OS X.&lt;br&gt;
&lt;br&gt;
Thanks all.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.13714-236811</guid>
		<pubDate>Thu, 06 Jan 2005 16:34:36 -0800</pubDate>
		<dc:creator>mecran01</dc:creator>
	</item><item>
		<title>By: andrew cooke</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables#236819</link>	
		<description>be careful.  1215 pm is 1215 and not 2415.  the solutions above all make this mistake.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.13714-236819</guid>
		<pubDate>Thu, 06 Jan 2005 16:51:37 -0800</pubDate>
		<dc:creator>andrew cooke</dc:creator>
	</item><item>
		<title>By: rajbot</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables#236821</link>	
		<description>&lt;i&gt;Oh, I&apos;m running OS X.&lt;/i&gt;&lt;br&gt;
&lt;br&gt;
On the command-line, you can type &quot;man perlretut&quot; to get the Perl regular expressions tutorial. The &quot;perlre&quot; is pretty useful.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.13714-236821</guid>
		<pubDate>Thu, 06 Jan 2005 16:56:51 -0800</pubDate>
		<dc:creator>rajbot</dc:creator>
	</item><item>
		<title>By: Zed_Lopez</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables#236826</link>	
		<description>perl -pi.bak -e &apos;s/(\d{4})PM/($1&amp;lt;1200 ? $1+1200 : $1)/ge&apos;  filename&lt;br&gt;
&lt;br&gt;
This fixes the 2415 bug and the problem by which it wasn&apos;t getting multiple hits on one line.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.13714-236826</guid>
		<pubDate>Thu, 06 Jan 2005 17:08:30 -0800</pubDate>
		<dc:creator>Zed_Lopez</dc:creator>
	</item><item>
		<title>By: mecran01</title>
		<link>http://ask.metafilter.com/13714/Using-Grep-within-BBedit-to-change-some-data-in-tables#237204</link>	
		<description>Last night I ran &lt;b&gt;Neustile&lt;/b&gt;&apos;s script, which worked great, then this morning I ran your revision, which also worked.  I saw the 2415 bug, but there were only two expressions of it in the final, which were easier to fix.&lt;br&gt;
&lt;br&gt;
This code is going to become part of a larger project that will take 300 excel entries, plop them into mysql, and make them searchable in complex ways via a web interface.  Not that it matters, but in the long run it is going to make things easier for a handful of people in an English department who do scheduling.&lt;br&gt;
&lt;br&gt;
Even cooler is I can pick apart your examples and learn to do something incredibly useful with my ibook: command line search and replaces.  Again, many thanks for the mini-tutorials.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2005:site.13714-237204</guid>
		<pubDate>Fri, 07 Jan 2005 08:08:43 -0800</pubDate>
		<dc:creator>mecran01</dc:creator>
	</item>
	</channel>
</rss>
