<?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>Ask MetaFilter questions tagged with regularexpression</title>
      <link>http://ask.metafilter.com/tags/regularexpression</link>
      <description>Questions tagged with 'regularexpression' at Ask MetaFilter.</description>
	  <pubDate>Wed, 10 Jun 2009 16:30:20 -0800</pubDate> <lastBuildDate>Wed, 10 Jun 2009 16:30:20 -0800</lastBuildDate>

      <language>en-us</language>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <ttl>60</ttl>	  
	<item>
	<title>Shell script handling CSV columns</title>
	<link>http://ask.metafilter.com/124463/Shell%2Dscript%2Dhandling%2DCSV%2Dcolumns</link>	
	<description>I&apos;m using a shell script to handle some excel docs by converting to csv and reformatting it a little bit. I&apos;m having some difficulty going on with the next part of the script. Some help would be great. :) CURRENT SCRIPT:&lt;br&gt;
#!/bin/sh&lt;br&gt;
ls *.xls&lt;br&gt;
echo &quot;Enter filename for excel input file: &quot;&lt;br&gt;
read filen&lt;br&gt;
xls2csv -x &quot;$filen&quot;&quot;.xls&quot; -b WINDOWS-1252 -c &quot;$filen&quot;&quot;.csv&quot; -a UTF-8&lt;br&gt;
sed &apos;1,3d&apos; &quot;$filen&quot;.csv &amp;gt;&quot;$filen&quot;_temp.csv&lt;br&gt;
cut -d &quot;,&quot; -f 1,4- &quot;$filen&quot;_temp.csv &amp;gt; &quot;$filen&quot;_temp2.csv&lt;br&gt;
awk -F, &apos;{sub($NF, &quot;&quot;);print}&apos; &quot;$filen&quot;_temp2.csv &amp;gt; &quot;$filen&quot;_temp3.csv&lt;br&gt;
sed &apos;s/.$//&apos; &quot;$filen&quot;_temp3.csv &amp;gt; &quot;$filen&quot;_fixed.csv&lt;br&gt;
rm &quot;$filen&quot;.csv&lt;br&gt;
rm &quot;$filen&quot;_temp.csv&lt;br&gt;
rm &quot;$filen&quot;_temp2.csv&lt;br&gt;
rm &quot;$filen&quot;_temp3.csv&lt;br&gt;
echo &quot;$filen&quot;&quot;.xls corrected and saved as &quot;&quot;$filen&quot;&quot;_fixed.csv&quot;&lt;br&gt;
&lt;br&gt;
EXAMPLE OUTPUT (first three lines only):&lt;br&gt;
&quot;Device ID&quot;,&quot;1) S31 Which best describes how you answered the online reading comprehension quiz?&quot;,&quot;2) S32 Which best describes how you answered the online timed retrieval quiz?&quot;,&quot;3) B19. If you want your product to be easy to find in the supermarket then you should make its container&quot;,&quot;4) C19.  So that he can shift attention between the radio and his incessantly talking girl friend when she is in the car, Joe adjusts his radio&quot;,&quot;5) B20.  Early selection is most likely to occur for&quot;,&quot;6) C20.  Early selection for a red target is most likely to occur when there is&quot;,&quot;7) B21. In a lexical decision task, when the target is a bird name, e.g. robin, it is usually preceded by the prime BODY but is sometimes preceded by the prime BIRD.&quot;,&quot;8) C21.  In a lexical decision task, when the target is a dog name, e.g. collie, it is usually preceded by the prime CAR but is sometimes preceded by the prime DOG.&quot;,&quot;9) B23. Suppose that that you see a brief display with 12 colored letters: 4 red, 4 white, and 4 blue.  At the offset of the display you hear tone.  A tone instructs you to report only the letters of a particular color: high for red, medium for white, and low for blue.  About how many letters do you report?&quot;,&quot;10) B22.  Sperling (1960) found that partial report produced the highest estimate of the number of available letters when the tone occurred &quot;,&quot;11) C23.  According to the logic of Sperling&#8217;s (1960) partial report method, an observer who reports three letters from a row in a 4 x 4 display that was cued at the display&#8217;s offset must have seen at least&quot;,&quot;12) C22.  Sperling (1960) found that the greatest difference between full and partial report in the number available of letters was when the tone occurred ____ milliseconds after the offset of the visual display&quot;&lt;br&gt;
96A39,6,4,&quot;4 c&quot;,&quot;4 c&quot;,&quot;5 c&quot;,&quot;5 c&quot;,&quot;5 c&quot;,&quot;4 i&quot;,&quot;3 c&quot;,&quot;1 c&quot;,&quot;1 i&quot;,&quot;5 i&quot;&lt;br&gt;
1E90A4,5,3,&quot;4 c&quot;,&quot;4 c&quot;,&quot;5 c&quot;,&quot;5 c&quot;,&quot;2 i&quot;,&quot;5 c&quot;,&quot;3 c&quot;,&quot;1 c&quot;,&quot;4 i&quot;,&quot;4 i&quot;&lt;br&gt;
&lt;br&gt;
First, I need to remove the numbering of the questions from the first line. So &quot;1) S31 Which best describes how you answered the online reading comprehension quiz?&quot; would become &quot;S31 Which best describes how you answered the online reading comprehension quiz?&quot;&lt;br&gt;
&lt;br&gt;
Next I need to remove an entire column if its row header doesn&apos;t begin with either B or C or is the &quot;Device ID&quot; column. For example, column starting with B19 is kept, the C23 is kept, and&quot;Device ID&quot; column is kept. The column with the question starting S31 must be entirely removed.&lt;br&gt;
&lt;br&gt;
Thanks.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.124463</guid>
	<pubDate>Wed, 10 Jun 2009 16:30:20 -0800</pubDate>
	<category>bash</category>
	<category>csv</category>
	<category>excel</category>
	<category>grep</category>
	<category>linux</category>
	<category>perl</category>
	<category>regexp</category>
	<category>regularexpression</category>
	<category>script</category>
	<category>shell</category>
	<category>unix</category>
	<dc:creator>fightoplankton</dc:creator>
	</item>
	<item>
	<title>Regular Expression Ninja</title>
	<link>http://ask.metafilter.com/91426/Regular%2DExpression%2DNinja</link>	
	<description>I want to become a regular expression ninja (a black belt). Where should I start? I&apos;d prefer something interactive (vs. a book or blog post), like a website where I can test them out. I found &lt;a href=&quot;http://gskinner.com/RegExr/&quot;&gt;this&lt;/a&gt; site, and it&apos;s OK, but are there any others to choose from?</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2008:site.91426</guid>
	<pubDate>Wed, 14 May 2008 16:26:19 -0800</pubDate>
	<category>regexp</category>
	<category>regularexpression</category>
	<dc:creator>JPowers</dc:creator>
	</item>
	<item>
	<title>Regex Alms for the Perl-less?</title>
	<link>http://ask.metafilter.com/79601/Regex%2DAlms%2Dfor%2Dthe%2DPerlless</link>	
	<description>Help me composite some regex.

&lt;small&gt;(That phrasing makes this question sound &lt;em&gt;way&lt;/em&gt; less nerdy than it is)&lt;/small&gt; Here&apos;s a regex to find some stuff between square brackets:&lt;br&gt;
/\[[^\]]+\]/&lt;br&gt;
&lt;br&gt;
Here&apos;s one that finds something like Alt: or alt. or Alternative: or alternate or Alternate: or Alternative or Alt.: or you get the idea [note it ends with \s+; it is important for my application that the &quot;Alt___ &quot; I&apos;m testing for has white space at the end, and that I test for it. In the final answer we can test for that word boundary any way we like, we just need to make sure that we &lt;em&gt;do&lt;/em&gt;.]:&lt;br&gt;
/(A|a)lt(\.|ernat(e|ive))?:?\s+/&lt;br&gt;
&lt;br&gt;
So what I need is a regular expression for &quot;stuff between square brackets where the first thing inside the brackets will NOT match the second regex.&quot; Or &quot;Stuff inside square brackets that begins with anything BUT alt or Alt. or Alternate or alternative: or alt.: or etc. etc.&lt;br&gt;
&lt;br&gt;
I feel like this should be easy, but I never bothered to totally and completely grok regex, and obviously I&apos;m hurting now because of it.  I&apos;d very much appreciate any help anyone could give, and in exchange you&apos;ll get co-author credit for the &lt;strong&gt;amazing&lt;/strong&gt; piece of software that this thing will ultimately be a part of!  ;-)</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2007:site.79601</guid>
	<pubDate>Fri, 28 Dec 2007 02:12:28 -0800</pubDate>
	<category>headache</category>
	<category>perl</category>
	<category>regex</category>
	<category>regularexpression</category>
	<category>regularexpressions</category>
	<dc:creator>ChasFile</dc:creator>
	</item>
	<item>
	<title>I&apos;d like to redirect an entire directory to one specific file.</title>
	<link>http://ask.metafilter.com/58651/Id%2Dlike%2Dto%2Dredirect%2Dan%2Dentire%2Ddirectory%2Dto%2Done%2Dspecific%2Dfile</link>	
	<description>301 redirectrs in .htaccess: how do I redirect calendar/* to /calendar.html ?  I&apos;ve tried modifying various examples online and they result in either &quot;internal server error&quot; or a 404 caused by incorrectly redirecting /calendar/* to /calendar.html/* . Two examples from the experimentation (I&apos;m in over my head; I just want this to work):&lt;br&gt;
&lt;br&gt;
# redirect 301 /calendar http://www.domain.com/calendar.html&lt;br&gt;
# 404 due to mistake above.&lt;br&gt;
&lt;br&gt;
# RedirectMatch 301 ^/calendar/(.*).htm$ http://www.domain.com/calendar.html [L]&lt;br&gt;
# internal server error</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2007:site.58651</guid>
	<pubDate>Tue, 13 Mar 2007 20:10:18 -0800</pubDate>
	<category>301redirect</category>
	<category>htaccess</category>
	<category>redirect</category>
	<category>regex</category>
	<category>regularexpression</category>
	<category>resolved</category>
	<category>wildcard</category>
	<dc:creator>Tuwa</dc:creator>
	</item>
	
	</channel>
</rss>

