<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Regex Challenge</title>
	<atom:link href="http://ubuntu-tutorials.com/2008/11/17/regex-challenge/feed/" rel="self" type="application/rss+xml" />
	<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/</link>
	<description>Enhancing your Ubuntu experience!</description>
	<lastBuildDate>Thu, 02 Feb 2012 10:29:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: G N</title>
		<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/#comment-7624</link>
		<dc:creator>G N</dc:creator>
		<pubDate>Fri, 02 Jan 2009 16:46:40 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=918#comment-7624</guid>
		<description>I second &quot;grep .&quot; as the easiest solution.

Perl/Ruby shouldn&#039;t be too complicated either:

perl -lane &#039;print if /./&#039;
ruby -lane &#039;p if /./&#039;

Too filter whitespace lines (not only blanks):

perl -lane &#039;print if /\S/&#039;
ruby -lane &#039;print if /\S/&#039;</description>
		<content:encoded><![CDATA[<p>I second &#8220;grep .&#8221; as the easiest solution.</p>
<p>Perl/Ruby shouldn&#8217;t be too complicated either:</p>
<p>perl -lane &#8216;print if /./&#8217;<br />
ruby -lane &#8216;p if /./&#8217;</p>
<p>Too filter whitespace lines (not only blanks):</p>
<p>perl -lane &#8216;print if /\S/&#8217;<br />
ruby -lane &#8216;print if /\S/&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Khalil Fazal</title>
		<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/#comment-7389</link>
		<dc:creator>Khalil Fazal</dc:creator>
		<pubDate>Fri, 05 Dec 2008 02:22:53 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=918#comment-7389</guid>
		<description>emacs22

C-M-%

C-q C-j C-q C-j +

C-q C-j

and it will then ask you &quot;[y/n]?&quot;</description>
		<content:encoded><![CDATA[<p>emacs22</p>
<p>C-M-%</p>
<p>C-q C-j C-q C-j +</p>
<p>C-q C-j</p>
<p>and it will then ask you &#8220;[y/n]?&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wolfger</title>
		<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/#comment-6969</link>
		<dc:creator>Wolfger</dc:creator>
		<pubDate>Thu, 20 Nov 2008 15:35:23 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=918#comment-6969</guid>
		<description>Late to the challenge, but here&#039;s the regex I whipped out off the top of my head:
s/\n\W*\n/\n/g

My perl code slurps the entire file to a variable and regexes that variable, then splits on newline to an array.</description>
		<content:encoded><![CDATA[<p>Late to the challenge, but here&#8217;s the regex I whipped out off the top of my head:<br />
s/\n\W*\n/\n/g</p>
<p>My perl code slurps the entire file to a variable and regexes that variable, then splits on newline to an array.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/#comment-6933</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Wed, 19 Nov 2008 13:27:24 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=918#comment-6933</guid>
		<description>Hm... why do I have to post this three times? :-/

awk -v RS=&quot;[\n ,]+&quot; &#039;{print}&#039; &lt; u.txt</description>
		<content:encoded><![CDATA[<p>Hm&#8230; why do I have to post this three times? :-/</p>
<p>awk -v RS=&#8221;[\n ,]+&#8221; &#8216;{print}&#8217; &lt; u.txt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: meyer</title>
		<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/#comment-6909</link>
		<dc:creator>meyer</dc:creator>
		<pubDate>Tue, 18 Nov 2008 22:05:55 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=918#comment-6909</guid>
		<description>boo that should be foreach \...</description>
		<content:encoded><![CDATA[<p>boo that should be foreach \&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: meyer</title>
		<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/#comment-6908</link>
		<dc:creator>meyer</dc:creator>
		<pubDate>Tue, 18 Nov 2008 22:04:46 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=918#comment-6908</guid>
		<description>#!/usr/bin/perl
open(FILE,&quot;usernames.txt&quot;) &#124;&#124; die &quot;Could not open usernames.txt: $!\n&quot;;
foreach () {if ($_ =~ /\w+/) {print &quot;$_&quot;}}
close(FILE);


Of course you&#039;d have to be crazy to use perl for something that easy in grep/awk!!</description>
		<content:encoded><![CDATA[<p>#!/usr/bin/perl<br />
open(FILE,&#8221;usernames.txt&#8221;) || die &#8220;Could not open usernames.txt: $!\n&#8221;;<br />
foreach () {if ($_ =~ /\w+/) {print &#8220;$_&#8221;}}<br />
close(FILE);</p>
<p>Of course you&#8217;d have to be crazy to use perl for something that easy in grep/awk!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: adam-collard</title>
		<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/#comment-6907</link>
		<dc:creator>adam-collard</dc:creator>
		<pubDate>Tue, 18 Nov 2008 21:13:06 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=918#comment-6907</guid>
		<description>import sys

for line in sys.stdin:
    usernames = [name.strip() for name in line.split(&quot;,&quot;)]
    if not any(usernames):
        continue
    for username in usernames:
        print username

Readability - 1
The way of the Pathologically Eclectic Rubbish Lister - 0</description>
		<content:encoded><![CDATA[<p>import sys</p>
<p>for line in sys.stdin:<br />
    usernames = [name.strip() for name in line.split(",")]<br />
    if not any(usernames):<br />
        continue<br />
    for username in usernames:<br />
        print username</p>
<p>Readability &#8211; 1<br />
The way of the Pathologically Eclectic Rubbish Lister &#8211; 0</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kai</title>
		<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/#comment-6893</link>
		<dc:creator>Kai</dc:creator>
		<pubDate>Tue, 18 Nov 2008 15:18:17 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=918#comment-6893</guid>
		<description>Just delete blank lines:
perl -pi -e &#039;s/\A\s+\z//&#039; usernames.txt
With commas too:
perl -pi -e &#039;s/,\s*/\n/g;s/\A\s+\z//&#039; usernames.txt</description>
		<content:encoded><![CDATA[<p>Just delete blank lines:<br />
perl -pi -e &#8216;s/\A\s+\z//&#8217; usernames.txt<br />
With commas too:<br />
perl -pi -e &#8216;s/,\s*/\n/g;s/\A\s+\z//&#8217; usernames.txt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Schroeder</title>
		<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/#comment-6889</link>
		<dc:creator>Jeff Schroeder</dc:creator>
		<pubDate>Tue, 18 Nov 2008 13:53:55 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=918#comment-6889</guid>
		<description>Regex can be avoided in most cases and should be when possible.

Try this:
awk &#039;/^[a-zA-Z]/{print $1}&#039; usernames.txt

Unlike just removing the newlines, that prevents cases where some crazy admin has commented out users or whatnot in /etc/passwd.

If that was a standard passwd file you could do something more like:
awk -F: &#039;/^[a-zA-Z]/{if ($3 !~ 0) print $1}&#039; /etc/passwd

If it is and Ubuntu / Debian server where normal uids start at 1000, you could do this for a listing of usernames:
awk -F: &#039;/^[a-zA-Z]/{if ($3 &gt;= 1000 &amp;&amp; $1 != &quot;nobody&quot;) print $1}&#039; /etc/passwd

Usernames must start with a character and can&#039;t start with a number from my understanding so that should work fairly well.</description>
		<content:encoded><![CDATA[<p>Regex can be avoided in most cases and should be when possible.</p>
<p>Try this:<br />
awk &#8216;/^[a-zA-Z]/{print $1}&#8217; usernames.txt</p>
<p>Unlike just removing the newlines, that prevents cases where some crazy admin has commented out users or whatnot in /etc/passwd.</p>
<p>If that was a standard passwd file you could do something more like:<br />
awk -F: &#8216;/^[a-zA-Z]/{if ($3 !~ 0) print $1}&#8217; /etc/passwd</p>
<p>If it is and Ubuntu / Debian server where normal uids start at 1000, you could do this for a listing of usernames:<br />
awk -F: &#8216;/^[a-zA-Z]/{if ($3 &gt;= 1000 &amp;&amp; $1 != &#8220;nobody&#8221;) print $1}&#8217; /etc/passwd</p>
<p>Usernames must start with a character and can&#8217;t start with a number from my understanding so that should work fairly well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Drago</title>
		<link>http://ubuntu-tutorials.com/2008/11/17/regex-challenge/#comment-6885</link>
		<dc:creator>Mark Drago</dc:creator>
		<pubDate>Tue, 18 Nov 2008 12:52:14 +0000</pubDate>
		<guid isPermaLink="false">http://ubuntu-tutorials.com/?p=918#comment-6885</guid>
		<description>Mackenzie:
sed -e &#039;s/,/\n/g&#039; -e &#039;s/[ \t]//g&#039; -e &#039;/^$/d&#039; usernames.txt

Converts commas to newlines, strips whitespace, then removes blanks.

Mark.</description>
		<content:encoded><![CDATA[<p>Mackenzie:<br />
sed -e &#8216;s/,/\n/g&#8217; -e &#8216;s/[ \t]//g&#8217; -e &#8216;/^$/d&#8217; usernames.txt</p>
<p>Converts commas to newlines, strips whitespace, then removes blanks.</p>
<p>Mark.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: basic (User agent is rejected)
Database Caching 1/6 queries in 0.004 seconds using disk: basic
Object Caching 309/310 objects using disk: basic

Served from: ubuntu-tutorials.com @ 2012-02-09 15:29:56 -->
