<?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: Use a regular expression to parse a directory tree</title>
      <link>http://ask.metafilter.com/36138/Use-a-regular-expression-to-parse-a-directory-tree/</link>
      <description>Comments on Ask MetaFilter post Use a regular expression to parse a directory tree</description>
	  	  <pubDate>Tue, 11 Apr 2006 11:38:24 -0800</pubDate>
      <lastBuildDate>Tue, 11 Apr 2006 11:38:24 -0800</lastBuildDate>
      <language>en-us</language>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <ttl>60</ttl>

<item>
  	<title>Question: Use a regular expression to parse a directory tree</title>
  	<link>http://ask.metafilter.com/36138/Use-a-regular-expression-to-parse-a-directory-tree</link>	
  	<description>I&apos;m trying to write a regex that gets passed into a java class to validate that a file is in a certain directory structure. &lt;br /&gt;&lt;br /&gt; Okay folks here&apos;s the deal.  I have a closed source java class with a method that will tell me if a particular web resource is in one of it&apos;s predefined directory structures. The directory structures are defined as regular expressions in an XML file like this:&lt;br&gt;
&lt;br&gt;
&lt;directory&gt;/var/www/.*&lt;/directory&gt;&lt;br&gt;
&lt;directory&gt;/home/user1/www/.*&lt;/directory&gt;&lt;br&gt;
&lt;br&gt;
I pass in the real path to a published jsp or some other file like this one:&lt;br&gt;
&lt;br&gt;
/home/user1/www/test.jsp&lt;br&gt;
&lt;br&gt;
and this method should return true if the file is in one of it&apos;s configured directory structures.&lt;br&gt;
&lt;br&gt;
I&apos;m trying to write a regular expression that will match all files/directories in the /home file tree except for a single user.  Something like:&lt;br&gt;
&lt;br&gt;
&lt;directory&gt;/home/.*&lt;/directory&gt;&lt;br&gt;
&lt;directory&gt;/home/^user2&lt;/directory&gt;&lt;br&gt;
&lt;br&gt;
but i want it in a single regular expression.  That way if i pass in /home/user1/test.jsp I get a true but if I pass in /home/user2/test.jsp I get a false.    I&apos;ve been toying with something like &quot;/home/[.*&amp;amp;&amp;amp;[^(user2/.*)]]&quot; but it doesn&apos;t work.  Hopefully that makes sense.  Anyone, anyone?</description>
  	<guid isPermaLink="false">post:ask.metafilter.com,2008:site.36138</guid>
  	<pubDate>Tue, 11 Apr 2006 11:25:49 -0800</pubDate>
  	<dc:creator>toomuch</dc:creator>
	
	<category>regex</category>
	
</item>
<item>
  	<title>By: kenko</title>
  	<link>http://ask.metafilter.com/36138/Use-a-regular-expression-to-parse-a-directory-tree#561487</link>	
  	<description>Can&apos;t test this thoroughly now but try:&lt;br&gt;
/home(?!/user2)/.*</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.36138-561487</guid>
  	<pubDate>Tue, 11 Apr 2006 11:38:24 -0800</pubDate>
  	<dc:creator>kenko</dc:creator>
</item>
<item>
  	<title>By: kenko</title>
  	<link>http://ask.metafilter.com/36138/Use-a-regular-expression-to-parse-a-directory-tree#561490</link>	
  	<description>/home/(?!user2).* is a more straightforward version of that.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.36138-561490</guid>
  	<pubDate>Tue, 11 Apr 2006 11:40:23 -0800</pubDate>
  	<dc:creator>kenko</dc:creator>
</item>
<item>
  	<title>By: toomuch</title>
  	<link>http://ask.metafilter.com/36138/Use-a-regular-expression-to-parse-a-directory-tree#561491</link>	
  	<description>Duh a lookahead.  I can&apos;t believe it was that simple.  Thanks kenko, you&apos;re a genius.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.36138-561491</guid>
  	<pubDate>Tue, 11 Apr 2006 11:42:13 -0800</pubDate>
  	<dc:creator>toomuch</dc:creator>
</item>

    </channel>
</rss>
