<?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 regexp</title>
      <link>http://ask.metafilter.com/tags/regexp</link>
      <description>Questions tagged with 'regexp' at Ask MetaFilter.</description>
	  <pubDate>Mon, 14 Sep 2009 19:22:28 -0800</pubDate> <lastBuildDate>Mon, 14 Sep 2009 19:22:28 -0800</lastBuildDate>

      <language>en-us</language>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <ttl>60</ttl>	  
	<item>
	<title>To the (regexpmobile|globmobile) Robin!</title>
	<link>http://ask.metafilter.com/132865/To%2Dthe%2Dregexpmobileglobmobile%2DRobin</link>	
	<description>Can I use shell style globs or something like regexp to search for online content? I want to be able to search for &apos;*mobile&apos; or &apos;.*mobile$&apos; or something similar and get something like &quot;bookmobile, popemobile, spacemobile, pimpmobile, weinermobile ...&quot; as a result.&lt;br&gt;
&lt;br&gt;
I am looking for a general way to search for things like this based on internet (particularly web) usage, not just a list of compound words that end in mobile.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.132865</guid>
	<pubDate>Mon, 14 Sep 2009 19:22:28 -0800</pubDate>
	<category>glob</category>
	<category>internet</category>
	<category>mobile</category>
	<category>regexp</category>
	<category>search</category>
	<category>unresolved</category>
	<dc:creator>idiopath</dc:creator>
	</item>
	<item>
	<title>down by the river - regex and poker cards</title>
	<link>http://ask.metafilter.com/126117/down%2Dby%2Dthe%2Driver%2Dregex%2Dand%2Dpoker%2Dcards</link>	
	<description>looking for regex expert to help with replacing playing card references Hello mefite regex experts!&lt;br&gt;
&lt;br&gt;
I am trying to process a string to find and replace playing card references.  When texas hold &#8216;em poker players express playing cards they use a number of formats, for example &#8216;7-7&#8217; to indicate a pair of sevens or &#8216;7-8-9&#8217; to show the three card flop.   They also show cards with their suits, for example &#8216;kc-kd-kh&#8217; to show king clubs, king diamonds and king hearts.  However, the &#8216;-&#8216; are arbitrary, they could use spaces &#8216;kc kd kh&#8217;, commas etc. AND they are variable length, so I need to find &#8216;A-A&#8217; &#8216;7-8-9-10-j&#8217; and &#8216;7c-8c-9c-10c&#8217;.&lt;br&gt;
&lt;br&gt;
I want to find these strings and replace them with HTML (using ColdFusion) and I am looking to the regexp which will allow me to process things like:&lt;br&gt;
&lt;br&gt;
&#8216;xCx&#8217; or &#8216;xCxCx&#8217; or &#8216;xCxCxCx&#8217; or &#8216;xCxCxCxCx&#8217; or &#8216;xCxCxCxCxCx&#8217; where &#8216;x&#8217; is any one of a number of special characters (space, comma, !, period, -, etc.) and &#8216;C&#8217; is one of 2,3,4,5,6,7,8,9,10,j,q,k,a. (casing to be ignored)&lt;br&gt;
&lt;br&gt;
I also need to find and replace &#8216;xCSx&#8217;, &#8216;xCSxCSx&#8217;, etc, where &#8216;S&#8217; is the suit &#8211; c, h, d or s.&lt;br&gt;
&lt;br&gt;
One further complication is that when I replace the suit (&#8216;S&#8217;) string, I need to replace it with the HTML symbol - &amp;amp;spades; etc. and wrap a class around it so &#8216; KC &#8217; would become &#8216; [span class=&#8217;card&#8217;] K [span class=&#8217;blacksuit&#8217;]&amp;clubs;[/span] [/span] &#8217;. &lt;br&gt;
&lt;br&gt;
(I am using [ ] instead of angle brackets to preserver the formatting!).&lt;br&gt;
&lt;br&gt;
Is this possible?  Is it too much for a single regexp???  Thanks for all help!</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.126117</guid>
	<pubDate>Mon, 29 Jun 2009 13:40:58 -0800</pubDate>
	<category>coldfusion</category>
	<category>regexp</category>
	<category>resolved</category>
	<dc:creator>the_very_hungry_caterpillar</dc:creator>
	</item>
	<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>URL rewrite in IIS7: make foo.com/bah/ redirect to example.com/foo/bah/</title>
	<link>http://ask.metafilter.com/113872/URL%2Drewrite%2Din%2DIIS7%2Dmake%2Dfoocombah%2Dredirect%2Dto%2Dexamplecomfoobah</link>	
	<description>Help me with a URL rewrite in IIS7 I want to implement a rewrite in IIS that would allow the following without having to create a new rule for each one.&lt;br&gt;
&lt;br&gt;
www.foo.com/books/ redirects to www.example.com/foo/books/&lt;br&gt;
www.foo.com/films/ redirects to www.example.com/foo/films/&lt;br&gt;
www.foo.com/etc/ redirects to  www.example.com/foo/etc/&lt;br&gt;
www.foo.com/etc/etc/ redirects to  www.example.com/foo/etc/etc/&lt;br&gt;
&lt;br&gt;
I am familiar with the steps in &lt;a href=&quot;http://learn.iis.net/page.aspx/460/using-url-rewrite-module/&quot;&gt;using url rewrite module in IIS7&lt;/a&gt; if that makes passing on instructions a bit easier.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2009:site.113872</guid>
	<pubDate>Tue, 10 Feb 2009 12:10:29 -0800</pubDate>
	<category>IIS</category>
	<category>IIS7</category>
	<category>module</category>
	<category>redirect</category>
	<category>regexp</category>
	<category>rewrite</category>
	<category>URL</category>
	<dc:creator>furtive</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>Regexp seems great but how do I output the result?</title>
	<link>http://ask.metafilter.com/87474/Regexp%2Dseems%2Dgreat%2Dbut%2Dhow%2Ddo%2DI%2Doutput%2Dthe%2Dresult</link>	
	<description>I have a found out a regular expression that searches for a specific bit of text i want to extract from a html document (product names) in notepad++. Now i want to put all the matches of my expression in a new file. Can this be done? I tried using the macro recorder but didnt manage to find a solutions since it always go back to the first match. I also tried cygwin grep but never got it to work (I typed &quot;grep &apos;expression&apos; file&quot; but it returned the whole lines, not only the match).&lt;br&gt;
&lt;br&gt;
I also have excel if it will help.</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2008:site.87474</guid>
	<pubDate>Mon, 31 Mar 2008 08:28:56 -0800</pubDate>
	<category>notepad</category>
	<category>regexp</category>
	<category>regularexpressions</category>
	<dc:creator>ilike</dc:creator>
	</item>
	<item>
	<title>How to make regular expressions work with track changes?</title>
	<link>http://ask.metafilter.com/75099/How%2Dto%2Dmake%2Dregular%2Dexpressions%2Dwork%2Dwith%2Dtrack%2Dchanges</link>	
	<description>How can I make Microsoft Word&apos;s Find-and-Replace feature work properly with regular expressions when Track Changes is on? I&apos;m working on a document containing a significant number of citations with page ranges.  Many of those page ranges are separated by hyphens, and I need them to be separated by en dashes instead.&lt;br&gt;&lt;br&gt;So I&apos;m using Find and Replace with regular expressions like so:&lt;br&gt;&lt;strong&gt;Find what:&lt;/strong&gt;  ([0-9]{1,5})-([0-9]{1,5})&lt;br&gt;&lt;strong&gt;Replace with:&lt;/strong&gt; \1&#8211;\2&lt;br&gt;&lt;br&gt;Here&apos;s the problem:  If I run Replace All on the test sentence, &quot;Read pages 35-66, 87-92, &amp;amp; 105-22,&quot; I get back &quot;Read pages 35&#8211;66, 87&#8211;92, &amp;amp; 105&#8211;22.&quot;  Perfect.  But if I turn on Track Changes and run it, I get &quot;Read pages 3566&#8211;, 8792&#8211;, &amp;amp; 10522&#8211;.&quot;  I need these changes to be tracked.  Am I doomed to doing them by hand?&lt;br&gt;&lt;small&gt;I realize how this question looks to people who aren&apos;t grammar nerds or law students.  Trust me when I say that there is a difference, that the difference matters, and that the changes have to be tracked.&lt;/small&gt;</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2007:site.75099</guid>
	<pubDate>Wed, 31 Oct 2007 09:42:09 -0800</pubDate>
	<category>2003</category>
	<category>2007</category>
	<category>microsoft</category>
	<category>microsoftword</category>
	<category>msword</category>
	<category>office</category>
	<category>regexp</category>
	<category>regularexpressions</category>
	<category>trackchanges</category>
	<category>word</category>
	<dc:creator>Partial Law</dc:creator>
	</item>
	<item>
	<title>Python version of this Perl 4-line regexp script?</title>
	<link>http://ask.metafilter.com/50684/Python%2Dversion%2Dof%2Dthis%2DPerl%2D4line%2Dregexp%2Dscript</link>	
	<description>Convert perl to python: I am very comfortable with regular expressions but I need help converting an implementation of them from Perl to Python. I have an example Perl script below that opens a file, scans through it one line at a time, does a s// replace, then finds a string in the result and stores it in another variable. I would love to just have a working Python version of this for my edification-- and if you have any &quot;Perl to Python&quot; tutorial links I&apos;d love to see them. This code doesn&apos;t do much but it&apos;s a prime example of the sort of cruft I write in Perl every day for little things. I know about re.match and re.search but how do I do the rest?&lt;br&gt;
&lt;br&gt;
&lt;code&gt;&lt;br&gt;
open(L,&quot;/tmp/A&quot;);&lt;br&gt;
while(&amp;lt;L&amp;gt;) {&lt;br&gt;
     s/\#\#\#//;&lt;br&gt;
     if(/^ {1,3}[0-9]{1,3}\. http\:\/\/(.*)/) { print $1; }&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2006:site.50684</guid>
	<pubDate>Sat, 11 Nov 2006 16:46:11 -0800</pubDate>
	<category>perl</category>
	<category>python</category>
	<category>regexp</category>
	<dc:creator>neustile</dc:creator>
	</item>
	<item>
	<title>Is there a regexp for Excel?</title>
	<link>http://ask.metafilter.com/32380/Is%2Dthere%2Da%2Dregexp%2Dfor%2DExcel</link>	
	<description>ExcelFilter:  How do I convert a column of names formatted &lt;b&gt;&lt;i&gt;Smith, John&lt;/i&gt;&lt;/b&gt; into &lt;b&gt;&lt;i&gt;John Smith&lt;/i&gt;&lt;/b&gt;.  Feasible?</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2006:site.32380</guid>
	<pubDate>Thu, 09 Feb 2006 08:49:07 -0800</pubDate>
	<category>excel</category>
	<category>microsoft</category>
	<category>regexp</category>
	<category>spreadsheet</category>
	<category>textconversion</category>
	<category>visicalc</category>
	<dc:creator>furtive</dc:creator>
	</item>
	<item>
	<title>Dealing with HTML Parsing Misery?</title>
	<link>http://ask.metafilter.com/26171/Dealing%2Dwith%2DHTML%2DParsing%2DMisery</link>	
	<description>I need to write something (in perl) to shorten the text of a link if it&apos;s a URL, but only a URL. I&apos;ve played with a variety of regexps and banged my head against HTML::Parser, but I&apos;ve gotten no love. Help! As far as regexps, go, I&apos;ve done OK with &lt;tt&gt;/\&lt;a .*href=.*\&gt;(.*?)\&lt; \/a\&gt;/gi &lt;/&gt;&lt;/a&gt;&lt;/tt&gt; for getting the link text in question out, and modifying it isn&apos;t a problem.&lt;br&gt;
&lt;br&gt;
The problem arises when I try to put it back. All I&apos;ve been able to do is either only replace part of the orginal link OR I get stuck in an endless loop. I&apos;ve been escaping my &amp;gt; and &lt; signs, but that doesn&apos;t seem to help at all. for examples of what i&apos;ve been trying (where in each $z is a copy of the original $1 from the first regexp, and $modtxt is the text i want to replace), tt&gt;s#&quot;&amp;gt;$z\&lt; #$modtxt\#/tt&gt; will replace the text, but mungs up the tag so the initial A tag isn&apos;t closed before the ending tag. &lt;tt&gt;s#&quot;&amp;gt;$z\&lt; #\\&gt;$modtxt\&lt; #/tt&gt;, on the other hand, gets stuck in an endless loop.&lt;br&gt;
&lt;br&gt;
I&apos;ve been googling and banging my head against this for several days, and while I think I must be overlooking something really simple, I can&apos;t figure out what it is. Thus, I turn to Ask.Me for assistance.&lt;br&gt;
&lt;br&gt;
(btw, getting those regexps through was a surprisingly difficult undertaking)&lt;/&gt;&lt;/&gt;&lt;/tt&gt;&lt;/&gt;&lt;/&gt;</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2005:site.26171</guid>
	<pubDate>Wed, 26 Oct 2005 15:01:48 -0800</pubDate>
	<category>html</category>
	<category>perl</category>
	<category>regexp</category>
	<dc:creator>Captain_Tenille</dc:creator>
	</item>
	<item>
	<title>(How|Where) does one find Google&apos;s (guide|help) on (searching|querying) using regular expressions?</title>
	<link>http://ask.metafilter.com/21820/HowWhere%2Ddoes%2Done%2Dfind%2DGoogles%2Dguidehelp%2Don%2Dsearchingquerying%2Dusing%2Dregular%2Dexpressions</link>	
	<description>Well, what do you know, err.. what do I know, Google does &lt;a href=&quot;http://www.google.com/search?hl=en&amp;lr=&amp;safe=off&amp;q=%22%28I%7CHe%7CShe%29+%28can%7Cmay%7Cwill%29+%28search%7Cfind%7Clocate%29%22&amp;btnG=Search&quot;&gt;support&lt;/a&gt; some sort of regular expressions. However, I can&apos;t find the usage guide. Anyone?</description>
	<guid isPermaLink="false">tag:ask.metafilter.com,2005:site.21820</guid>
	<pubDate>Thu, 28 Jul 2005 04:34:41 -0800</pubDate>
	<category>google</category>
	<category>regex</category>
	<category>regexp</category>
	<category>regularexpressions</category>
	<category>search</category>
	<category>syntax</category>
	<category>tools</category>
	<category>use</category>
	<dc:creator>Gyan</dc:creator>
	</item>
	
	</channel>
</rss>

