<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Calcifer &#187; regex</title>
	<atom:link href="http://blog.calcifer.com.ar/tag/regex/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.calcifer.com.ar</link>
	<description></description>
	<lastBuildDate>Sat, 02 Oct 2010 05:32:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Validate an E-Mail Address with PHP</title>
		<link>http://blog.calcifer.com.ar/2008/07/validate-an-e-mail-address-with-php/</link>
		<comments>http://blog.calcifer.com.ar/2008/07/validate-an-e-mail-address-with-php/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 19:58:01 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[None]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2008/07/08/validate-an-e-mail-address-with-php/</guid>
		<description><![CDATA[From ILoveJackDaniel&#8217;s
function check_email_address&#40;$email&#41; &#123;
&#160; // First, we check that there's one @ symbol, 
&#160; // and that the lengths are right.
&#160; if &#40;!ereg&#40;&#34;^[^@]{1,64}@[^@]{1,255}$&#34;, $email&#41;&#41; &#123;
&#160; &#160; // Email invalid because wrong number of characters 
&#160; &#160; // in one section or wrong number of @ symbols.
&#160; &#160; return false;
&#160; &#125;
&#160; // Split it into sections [...]]]></description>
			<content:encoded><![CDATA[<p class="from">From <a href="http://www.ilovejackdaniels.com/php/email-address-validation" class="linkexternal">ILoveJackDaniel&#8217;s</a></p>
<div class="codecolorer-container php " style="overflow:auto;white-space:nowrap;width:435px;height:500px"><div class="php codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw2">function</span> check_email_address<span class="br0">&#40;</span><span class="re0">$email</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="co1">// First, we check that there's one @ symbol, </span><br />
&nbsp; <span class="co1">// and that the lengths are right.</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/ereg"><span class="kw3">ereg</span></a><span class="br0">&#40;</span><span class="st0">&quot;^[^@]{1,64}@[^@]{1,255}$&quot;</span><span class="sy0">,</span> <span class="re0">$email</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="co1">// Email invalid because wrong number of characters </span><br />
&nbsp; &nbsp; <span class="co1">// in one section or wrong number of @ symbols.</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="co1">// Split it into sections to make life easier</span><br />
&nbsp; <span class="re0">$email_array</span> <span class="sy0">=</span> <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;@&quot;</span><span class="sy0">,</span> <span class="re0">$email</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="re0">$local_array</span> <span class="sy0">=</span> <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span><span class="sy0">,</span> <span class="re0">$email_array</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$i</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$i</span> <span class="sy0">&lt;</span> <a href="http://www.php.net/sizeof"><span class="kw3">sizeof</span></a><span class="br0">&#40;</span><span class="re0">$local_array</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/ereg"><span class="kw3">ereg</span></a><span class="br0">&#40;</span><span class="st0">&quot;^(([A-Za-z0-9!#$%&amp;'*+/=?^_`{|}~-][A-Za-z0-9!#$%&amp;'*+/=?^_`{|}~\.-]{0,63})|(<span class="es1">\&quot;</span>[^(\\|<span class="es1">\&quot;</span>)]{0,62}<span class="es1">\&quot;</span>))$&quot;</span><span class="sy0">,</span> <span class="re0">$local_array</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="co1">// Check if domain is IP. If not, </span><br />
&nbsp; <span class="co1">// it should be valid domain name</span><br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/ereg"><span class="kw3">ereg</span></a><span class="br0">&#40;</span><span class="st0">&quot;^\[?[0-9\.]+\]?$&quot;</span><span class="sy0">,</span> <span class="re0">$email_array</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$domain_array</span> <span class="sy0">=</span> <a href="http://www.php.net/explode"><span class="kw3">explode</span></a><span class="br0">&#40;</span><span class="st0">&quot;.&quot;</span><span class="sy0">,</span> <span class="re0">$email_array</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/sizeof"><span class="kw3">sizeof</span></a><span class="br0">&#40;</span><span class="re0">$domain_array</span><span class="br0">&#41;</span> <span class="sy0">&lt;</span> <span class="nu0">2</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span> <span class="co1">// Not enough parts to domain</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$i</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$i</span> <span class="sy0">&lt;</span> <a href="http://www.php.net/sizeof"><span class="kw3">sizeof</span></a><span class="br0">&#40;</span><span class="re0">$domain_array</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/ereg"><span class="kw3">ereg</span></a><span class="br0">&#40;</span><span class="st0">&quot;^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$&quot;</span><span class="sy0">,</span> <span class="re0">$domain_array</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="kw1">return</span> <span class="kw2">true</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2008/07/validate-an-e-mail-address-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Renombrar recursivamente archivos y directorios</title>
		<link>http://blog.calcifer.com.ar/2008/06/renombrar-recursivamente-archivos-y-directorios/</link>
		<comments>http://blog.calcifer.com.ar/2008/06/renombrar-recursivamente-archivos-y-directorios/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 03:50:58 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[None]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[gnu/linux]]></category>
		<category><![CDATA[recursivity]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2008/06/10/renombrar-recursivamente-archivos-y-directorios/</guid>
		<description><![CDATA[El siguiente script de bash renombra archivos y directorios convirtiendo sus nombres a minúsculas, reemplazando espacios, acentos, eñes y eliminando paréntesis.
Por defecto renombra únicamente aquellos archivos y directorios ubicados en el directorio pasado como parámetro. Es posible usar la opción-r&#124;--recursivepara que trabaje recursivamente en todos los directorios hijos:
./rename.sh -r dir
Usando la opción-v&#124;--verbosees posible ver en [...]]]></description>
			<content:encoded><![CDATA[<p>El siguiente script de bash renombra archivos y directorios convirtiendo sus nombres a minúsculas, reemplazando espacios, acentos, eñes y eliminando paréntesis.</p>
<p>Por defecto renombra únicamente aquellos archivos y directorios ubicados en el directorio pasado como parámetro. Es posible usar la opción<code>-r|--recursive</code>para que trabaje recursivamente en todos los directorios hijos:</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">./rename.sh -r dir</div></div>
<p>Usando la opción<code>-v|--verbose</code>es posible ver en pantalla el listado de archivos modificados</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">./rename.sh -v -r dir</div></div>
<p>La opción<code>-t|--test</code>muestra un listado de cambios a realizar sin realizar ninguno</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">./rename.sh -t -r dir</div></div>
<h3>Ejemplo</h3>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px;height:300px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">xleo@calcifer:/tmp/music$ rename -t -r .<br />
/tmp/music/Jaime Roos/1998 - Concierto Aniversario<br />
./17 - Amándote.mp3 ./17_-_amandote.mp3<br />
./02 - Victoria Abaracón.mp3 ./02_-_victoria_abaracon.mp3<br />
./12 - Nadie Me Dijo Nada.mp3 ./12_-_nadie_me_dijo_nada.mp3<br />
./16 - Durazno Y Convención.mp3 ./16_-_durazno_y_convencion.mp3<br />
./01 - Si Me Voy Antes Que Vos-1.mp3 ./01_-_si_me_voy_antes_que_vos-1.mp3<br />
./03 - El Hombre De La Calle.mp3 ./03_-_el_hombre_de_la_calle.mp3<br />
./05 - Las Luces Del Estadio.mp3 ./05_-_las_luces_del_estadio.mp3<br />
./07 - Piropo.mp3 ./07_-_piropo.mp3<br />
./10 - Esta Noche.mp3 ./10_-_esta_noche.mp3<br />
./06 - Se Va La Murga.mp3 ./06_-_se_va_la_murga.mp3<br />
./08 - Los Futuros Murguistas.mp3 ./08_-_los_futuros_murguistas.mp3<br />
./15 - Tal Vez Cheché.mp3 ./15_-_tal_vez_cheche.mp3<br />
./13 - Bienvenido.mp3 ./13_-_bienvenido.mp3<br />
./1998 - Concierto Aniversario.m3u ./1998_-_concierto_aniversario.m3u<br />
./09 - Los Olímpicos.mp3 ./09_-_los_olimpicos.mp3<br />
./11 - Cometa De La Farola.mp3 ./11_-_cometa_de_la_farola.mp3<br />
./04 - Cuando Juega Uruguay.mp3 ./04_-_cuando_juega_uruguay.mp3<br />
./14 - El Tambor.mp3 ./14_-_el_tambor.mp3<br />
/tmp/music/Jaime Roos<br />
./1998 - Concierto Aniversario ./1998_-_concierto_aniversario<br />
/tmp/music<br />
./Jaime Roos ./jaime_roos</div></div>
<h3>rename.sh</h3>
<div class="codecolorer-container bash " style="overflow:auto;white-space:nowrap;width:435px;height:500px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br /></div></td><td><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#!/bin/bash</span><br />
<span class="co0">#</span><br />
<span class="co0"># @autor &nbsp; Leonardo Vidarte</span><br />
<span class="co0"># @version $Id rename.sh 5 2008-06-05 15:44:45Z xleo $</span><br />
<span class="co0">#</span><br />
<br />
<br />
<span class="co0"># ********</span><br />
<span class="co0"># INIT SET</span><br />
<span class="co0"># ********</span><br />
<span class="re2">verbose</span>=<span class="nu0">0</span><br />
<span class="re2">recursive</span>=<span class="nu0">0</span><br />
<span class="re2">MOVE</span>=<span class="sy0">/</span>bin<span class="sy0">/</span><span class="kw2">mv</span><br />
<span class="re2">ECHO</span>=<br />
<br />
<br />
<span class="co0"># ****</span><br />
<span class="co0"># HELP</span><br />
<span class="co0"># ****</span><br />
<span class="kw3">help</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="kw2">cat</span> <span class="co2">&lt;&lt; END<br />
Usage : rename [-t] [-v] [-r] directory<br />
<br />
Options:<br />
&nbsp; -v, --verbose &nbsp; &nbsp;verbose move<br />
&nbsp; -r, --recursive &nbsp;recursive rename<br />
&nbsp; -t, --test &nbsp; &nbsp; &nbsp; don't move, only show change list. Implies -v.<br />
&nbsp; -?, --help &nbsp; &nbsp; &nbsp; show this help<br />
<br />
END</span><br />
<span class="br0">&#125;</span><br />
<br />
<br />
<span class="co0"># ***************</span><br />
<span class="co0"># RENAME FUNCTION</span><br />
<span class="co0"># ***************</span><br />
rename <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw2">find</span> <span class="re5">-maxdepth</span> <span class="nu0">1</span> <span class="sy0">|</span> \<br />
&nbsp; &nbsp; <span class="kw2">awk</span> <span class="st_h">'{out=tolower($0); \<br />
&nbsp; &nbsp; gsub(&quot; ?\&amp; ?&quot;,&quot;_y_&quot;,out); \<br />
&nbsp; &nbsp; gsub(&quot;\(|\)&quot;,&quot;-&quot;,out); \<br />
&nbsp; &nbsp; gsub(&quot;[\340-\345]&quot;,&quot;a&quot;,out); \<br />
&nbsp; &nbsp; gsub(&quot;\347&quot;,&quot;c&quot;,out); \<br />
&nbsp; &nbsp; gsub(&quot;[\350-\353]&quot;,&quot;e&quot;,out); \<br />
&nbsp; &nbsp; gsub(&quot;[\354-\357]&quot;,&quot;i&quot;,out); \<br />
&nbsp; &nbsp; gsub(&quot;\361&quot;,&quot;n&quot;,out); \<br />
&nbsp; &nbsp; gsub(&quot;[\362-\366]&quot;,&quot;o&quot;,out); \<br />
&nbsp; &nbsp; gsub(&quot;[\371-\374]&quot;,&quot;u&quot;,out); \<br />
&nbsp; &nbsp; gsub(&quot;[^0-9a-z\./_-]&quot;,&quot;_&quot;,out); \<br />
&nbsp; &nbsp; if ($0!=out) {print &quot;\&quot;&quot;$0&quot;\&quot; &quot;out;}}'</span> <span class="sy0">|</span> \<br />
&nbsp; &nbsp; <span class="kw2">xargs</span> <span class="re5">-r</span> <span class="re5">-n</span> <span class="nu0">2</span> <span class="re1">$ECHO</span> <span class="re1">$MOVE</span><br />
<br />
<span class="br0">&#125;</span><br />
<br />
<br />
<span class="co0"># *************</span><br />
<span class="co0"># MAIN FUNCTION</span><br />
<span class="co0"># *************</span><br />
main <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<br />
<br />
&nbsp; &nbsp; <span class="co0"># ----------------</span><br />
&nbsp; &nbsp; <span class="co0"># Recursive rename</span><br />
&nbsp; &nbsp; <span class="co0"># ----------------</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re1">$recursive</span> <span class="re5">-eq</span> <span class="nu0">1</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="kw2">dir</span> <span class="kw1">in</span> <span class="st0">&quot;$1&quot;</span><span class="sy0">/*</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re5">-d</span> <span class="st0">&quot;<span class="es2">$dir</span>&quot;</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">cd</span> <span class="st0">&quot;<span class="es2">$dir</span>&quot;</span> <span class="sy0">&amp;&amp;</span> search <span class="st0">&quot;<span class="es2">$dir</span>&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">fi</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">done</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">fi</span><br />
<br />
<br />
&nbsp; &nbsp; <span class="co0"># ----------------------------</span><br />
&nbsp; &nbsp; <span class="co0"># Rename files and directories</span><br />
&nbsp; &nbsp; <span class="co0"># ----------------------------</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re1">$verbose</span> <span class="re5">-eq</span> <span class="nu0">1</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;$1&quot;</span><br />
&nbsp; &nbsp; <span class="kw1">fi</span><br />
<br />
&nbsp; &nbsp; <span class="kw3">cd</span> <span class="st0">&quot;$1&quot;</span> <span class="sy0">&amp;&amp;</span> rename<br />
<br />
<br />
<span class="br0">&#125;</span><br />
<br />
<br />
<span class="co0"># ***************************</span><br />
<span class="co0"># SHOW HELP WITHOUT ARGUMENTS</span><br />
<span class="co0"># ***************************</span><br />
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re4">$#</span> <span class="re5">-eq</span> <span class="nu0">0</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp;<span class="kw3">help</span><br />
&nbsp; &nbsp;<span class="kw3">exit</span> <span class="nu0">1</span><br />
<span class="kw1">fi</span><br />
<br />
<br />
<span class="co0"># *********</span><br />
<span class="co0"># SHOW HELP</span><br />
<span class="co0"># *********</span><br />
<span class="kw1">if</span> <span class="br0">&#91;</span><span class="br0">&#91;</span> <span class="st0">&quot;$1&quot;</span> =~ <span class="st_h">'(-h|--help)'</span> <span class="br0">&#93;</span><span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp;<span class="kw3">help</span><br />
&nbsp; &nbsp;<span class="kw3">exit</span> <span class="nu0">0</span><br />
<span class="kw1">fi</span><br />
<br />
<br />
<span class="co0"># ***************</span><br />
<span class="co0"># CHECK ARGUMENTS</span><br />
<span class="co0"># ***************</span><br />
<span class="kw1">while</span> <span class="br0">&#91;</span> <span class="re4">$#</span> <span class="re5">-gt</span> <span class="nu0">1</span> <span class="br0">&#93;</span>; <span class="kw1">do</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">case</span> <span class="st0">&quot;$1&quot;</span> <span class="kw1">in</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; -v<span class="sy0">|</span>--verbose<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">verbose</span>=<span class="nu0">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">MOVE</span>=<span class="st0">&quot;<span class="es2">$MOVE</span> --verbose&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">;;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; -r<span class="sy0">|</span>--recursive<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">recursive</span>=<span class="nu0">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">;;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; -t<span class="sy0">|</span>--test<span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">verbose</span>=<span class="nu0">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">MOVE</span>=<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">ECHO</span>=<span class="sy0">/</span>bin<span class="sy0">/</span><span class="kw3">echo</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">;;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">*</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">echo</span> invalid argument $<span class="nu0">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">help</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">exit</span> <span class="nu0">2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sy0">;;</span><br />
<br />
&nbsp; &nbsp; <span class="kw1">esac</span><br />
<br />
&nbsp; &nbsp; <span class="kw3">shift</span><br />
<br />
<span class="kw1">done</span><br />
<br />
<br />
<span class="co0"># ****************************************</span><br />
<span class="co0"># CHECK DIRECTORY AND INVOKE MAIN FUNCTION</span><br />
<span class="co0"># ****************************************</span><br />
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="st0">&quot;$1&quot;</span> == <span class="st_h">'.'</span> <span class="re5">-o</span> <span class="st0">&quot;$1&quot;</span> == <span class="st_h">'*'</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; <span class="re2"><span class="kw2">dir</span></span>=<span class="re1">$PWD</span><br />
<span class="kw1">else</span><br />
&nbsp; &nbsp; <span class="re2"><span class="kw2">dir</span></span>=$<span class="nu0">1</span><br />
<span class="kw1">fi</span><br />
<br />
<span class="kw1">if</span> <span class="br0">&#91;</span> <span class="re5">-d</span> <span class="st0">&quot;<span class="es2">$dir</span>&quot;</span> <span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; <span class="kw3">cd</span> <span class="st0">&quot;<span class="es2">$dir</span>&quot;</span><br />
&nbsp; &nbsp; <span class="re2"><span class="kw2">dir</span></span>=<span class="re1">$PWD</span><br />
&nbsp; &nbsp; <span class="kw3">cd</span> - <span class="nu0">1</span><span class="sy0">&gt;</span> <span class="sy0">/</span>dev<span class="sy0">/</span>null<br />
&nbsp; &nbsp; main <span class="st0">&quot;<span class="es2">$dir</span>&quot;</span><br />
&nbsp; &nbsp; <span class="kw3">exit</span> <span class="nu0">0</span><br />
<span class="kw1">else</span><br />
&nbsp; &nbsp; <span class="kw3">echo</span> rename: directory not found<br />
&nbsp; &nbsp; <span class="kw3">exit</span> <span class="nu0">3</span><br />
<span class="kw1">fi</span></div></td></tr></tbody></table></div>
<h3>Otro ejemplo</h3>
<p>Salida de<code>./rename -r -v /shared/music > <a href='http://blog.calcifer.com.ar/uploads/2008/06/result.txt' title='result.txt'>result.txt</a></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2008/06/renombrar-recursivamente-archivos-y-directorios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash Regular Expressions</title>
		<link>http://blog.calcifer.com.ar/2008/05/bash-regular-expressions/</link>
		<comments>http://blog.calcifer.com.ar/2008/05/bash-regular-expressions/#comments</comments>
		<pubDate>Tue, 27 May 2008 18:41:13 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[None]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[gnu/linux]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2008/05/28/bash-regular-expressions/</guid>
		<description><![CDATA[Vía www.linuxjournal.com
When working with regular expressions in a shell script the norm is to use grep or sed or some other external command/program. Since version 3 of bash (released in 2004) there is another option: bash&#8217;s built-in regular expression comparison operator &#8220;=~&#8221;.
Bash&#8217;s regular expression comparison operator takes a string on the left and an extended [...]]]></description>
			<content:encoded><![CDATA[<div class="from">Vía <a href="http://www.linuxjournal.com/content/bash-regular-expressions" class="linkexternal">www.linuxjournal.com</a></div>
<p>When working with regular expressions in a shell script the norm is to use grep or sed or some other external command/program. Since version 3 of bash (released in 2004) there is another option: bash&#8217;s built-in regular expression comparison operator &#8220;=~&#8221;.</p>
<p>Bash&#8217;s regular expression comparison operator takes a string on the left and an extended regular expression on the right. It returns 0 (success) if the regular expression matches the string, otherwise it returns 1 (failure).</p>
<p>In addition to doing simple matching, bash regular expressions support sub-patterns surrounded by parenthesis for capturing parts of the match. The matches are assigned to an array variable BASH_REMATCH. The entire match is assigned to BASH_REMATCH[0], the first sub-pattern is assigned to BASH_REMATCH[1], etc..</p>
<p>The following example script takes a regular expression as its first argument and one or more strings to match against. It then cycles through the strings and outputs the results of the match process:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px;height:300px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#!/bin.bash</span><br />
<br />
<span class="kw1">if</span> <span class="br0">&#91;</span><span class="br0">&#91;</span> <span class="re4">$#</span> <span class="re5">-lt</span> <span class="nu0">2</span> <span class="br0">&#93;</span><span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;Usage: $0 PATTERN STRINGS...&quot;</span><br />
&nbsp; &nbsp; <span class="kw3">exit</span> <span class="nu0">1</span><br />
<span class="kw1">fi</span><br />
<span class="re2">regex</span>=$<span class="nu0">1</span><br />
<span class="kw3">shift</span><br />
<span class="kw3">echo</span> <span class="st0">&quot;regex: <span class="es2">$regex</span>&quot;</span><br />
<span class="kw3">echo</span><br />
<br />
<span class="kw1">while</span> <span class="br0">&#91;</span><span class="br0">&#91;</span> $<span class="nu0">1</span> <span class="br0">&#93;</span><span class="br0">&#93;</span><br />
<span class="kw1">do</span><br />
&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span><span class="br0">&#91;</span> $<span class="nu0">1</span> =~ <span class="re1">$regex</span> <span class="br0">&#93;</span><span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;$1 matches&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">i</span>=<span class="nu0">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">n</span>=<span class="co1">${#BASH_REMATCH[*]}</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#91;</span><span class="br0">&#91;</span> <span class="re1">$i</span> <span class="re5">-lt</span> <span class="re1">$n</span> <span class="br0">&#93;</span><span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot; &nbsp;capture[<span class="es2">$i</span>]: <span class="es3">${BASH_REMATCH[$i]}</span>&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">let</span> i++<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">done</span><br />
&nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;$1 does not match&quot;</span><br />
&nbsp; &nbsp; <span class="kw1">fi</span><br />
&nbsp; &nbsp; <span class="kw3">shift</span><br />
<span class="kw1">done</span></div></div>
<p>Assuming the script is saved in &#8220;bashre.sh&#8221;, the following sample shows its output:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;width:435px"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0"># sh bashre.sh 'aa(b{2,3}[xyz])cc' aabbxcc aabbcc</span><br />
regex: aa<span class="br0">&#40;</span>b<span class="br0">&#123;</span><span class="nu0">2</span>,<span class="nu0">3</span><span class="br0">&#125;</span><span class="br0">&#91;</span>xyz<span class="br0">&#93;</span><span class="br0">&#41;</span><span class="kw2">cc</span><br />
<br />
aabbxcc matches<br />
&nbsp; capture<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>: bbx<br />
aabbcc does not match</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2008/05/bash-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Librándonos del ^M &#8211; mezclando dos y unix</title>
		<link>http://blog.calcifer.com.ar/2007/02/librandonos-del-m-mezclando-dos-y-unix/</link>
		<comments>http://blog.calcifer.com.ar/2007/02/librandonos-del-m-mezclando-dos-y-unix/#comments</comments>
		<pubDate>Tue, 27 Feb 2007 03:36:50 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[None]]></category>
		<category><![CDATA[gnu/linux]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2007/02/27/librandonos-del-m-mezclando-dos-y-unix/</guid>
		<description><![CDATA[Traducción Getting rid of ^M &#8211; mixing dos and unix
Al abrir archivos de otros SO podemos encontrarnos con^Mal final de cada línea:
import java.util.Hashtable; ^M
import java.util.Properties; ^Mimport java.io.IOException;
import org.xml.sax.AttributeList; ^M
import org.xml.sax.HandlerBase; ^Mimport org.xml.sax.SAXException;

/**^M
&#160; * XMLHandler: This class parses the elements contained^M
&#160; * within a XML message and builds a Hashtable^M
Algunos programas no son consistentes en la [...]]]></description>
			<content:encoded><![CDATA[<p class="ref">Traducción <a href="http://www.vim.org/tips/tip.php?tip_id=26" title="" class="external">Getting rid of ^M &#8211; mixing dos and unix</a></p>
<p>Al abrir archivos de otros SO podemos encontrarnos con<code>^M</code>al final de cada línea:</p>
<div class="codecolorer-container java " style="overflow:auto;white-space:nowrap;width:435px"><div class="java codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">import</span> <span class="co2">java.util.Hashtable</span><span class="sy0">;</span> <span class="sy0">^</span>M<br />
<span class="kw1">import</span> <span class="co2">java.util.Properties</span><span class="sy0">;</span> <span class="sy0">^</span>Mimport <span class="co2">java.io.IOException</span><span class="sy0">;</span><br />
<span class="kw1">import</span> <span class="co2">org.xml.sax.AttributeList</span><span class="sy0">;</span> <span class="sy0">^</span>M<br />
<span class="kw1">import</span> <span class="co2">org.xml.sax.HandlerBase</span><span class="sy0">;</span> <span class="sy0">^</span>Mimport <span class="co2">org.xml.sax.SAXException</span><span class="sy0">;</span><br />
<br />
<span class="coMULTI">/**^M<br />
&nbsp; * XMLHandler: This class parses the elements contained^M<br />
&nbsp; * within a XML message and builds a Hashtable^M</span></div></div>
<p>Algunos programas no son consistentes en la manera de insertar saltos de línea, entonces te encontrarás con algunas líneas que tienen un salto de línea y un<code>^M</code>y algunas que tengan un<code>^M</code>y no un salto de línea&#8230; con <a href="http://www.vim.org/" class="external">Vim</a> la limpieza se realiza en dos pasos:</p>
<p>1. reemplazar los ^M al final de cada línea:</p>
<div class="codecolorer-container vim " style="overflow:auto;white-space:nowrap;width:435px"><div class="vim codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">:%</span>s<span class="sy0">/^</span>M<span class="sy0">$//</span>g</div></div>
<p>Usar<code>"C-v C-m"</code>para escribir<code>^M</code>.</p>
<p>2. reemplazar todos los ^M&#8217;s que necesitan un salto de línea:</p>
<div class="codecolorer-container vim " style="overflow:auto;white-space:nowrap;width:435px"><div class="vim codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">:%</span>s<span class="sy0">/^</span>M<span class="sy0">/</span>n<span class="sy0">/</span>g</div></div>
<p>Voila! Archivo limpio.</p>
<p>Mas info en</p>
<div class="codecolorer-container vim " style="overflow:auto;white-space:nowrap;width:435px"><div class="vim codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">:</span>help ffs</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2007/02/librandonos-del-m-mezclando-dos-y-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comfortable editing with VIM</title>
		<link>http://blog.calcifer.com.ar/2006/10/comfortable-editing-with-vim/</link>
		<comments>http://blog.calcifer.com.ar/2006/10/comfortable-editing-with-vim/#comments</comments>
		<pubDate>Mon, 30 Oct 2006 18:21:32 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[None]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2006/10/30/comfortable-editing-with-vim/</guid>
		<description><![CDATA[Tomado del blog de Tobias Schlitt
Next occurrence of a word
If you hit*in command mode and your cursor resides on a word, you are taken to the next occurrence of the word. This is quite nice, if you like to know, where a function is called again.
Find matching brace
VIM 7.0 luckily highlights matching parenthesis, if your [...]]]></description>
			<content:encoded><![CDATA[<p class="from">Tomado del blog de <a href="http://schlitt.info/applications/blog/index.php?/archives/488-Comfortable-PHP-editing-with-VIM-5.html" title="" class="linkexternal">Tobias Schlitt</a></p>
<h3>Next occurrence of a word</h3>
<p>If you hit<code>*</code>in command mode and your cursor resides on a word, you are taken to the next occurrence of the word. This is quite nice, if you like to know, where a function is called again.</p>
<h3>Find matching brace</h3>
<p>VIM 7.0 luckily highlights matching parenthesis, if your cursor resides on a brace, but sometimes you need to quickly jump to that matching brace. You can achieve this by hitting the<code>%</code>sign in command mode.</p>
<h3>Repeat the last change</h3>
<p>It often occurs, that you need to perform 1 change several times, but not often enough to write a short script or to address the changes with a complex regex. In those cases you can perform the change once, move the cursor to the next place and hit the<code>.</code>(dot) char, in command mode.</p>
<p><span id="more-75"></span></p>
<h3>Enhanced functionality with external programs</h3>
<p>This tip is quite commonly known, but I repeat it here, because it&#8217;s really helpful: Although VIM has a huge set of useful functions, it does not have everything. If you don&#8217;t find a utility in VIM, you can simply use extern shell tools to perform certain tasks, by using<code>:!&lt;command&gt;</code>in command or visual mode. For example sorting a range of lines can easily be achieved with the following 2 steps: 1. Select the lines to sort in visual mode. 2. Type<code>:!sort</code>and hit return.</p>
<h3>Indenting and unindeting</h3>
<p>Especially when editing code, it happens often, that you have to indent/unindent a code block. If you use VIM&#8217;s auto-indenting features (like used by my .vimrc), VIM can do that job for you, too. Simply select the lines to (un-)indent in visual mode and hit<code>&lt;</code>to unindent 1 level or<code>&gt;</code>to indent 1 more level. This also works (as usual in VIM) with quantifiers like 4> to indent 4 more levels.</p>
<h3>Remote file editing</h3>
<p>Often you have to quickly edit a file on a remote server. Usually you SSH to that server or mount a remote file system locally, edit the desired file and quit the session again. VIM allows you to do this in 1 step, using SCP. On your shell type<code>vim scp://user@server//path/to/the/file</code>and VIM will edit the file directly through SCP.</p>
<h3>Recover the last visual selection</h3>
<p>It often happens, that you selected some text in visual mode, e.g. to perform a regex on it. Occasionally your regex is incorrect and you have to revert the changes or they don&#8217;t even happen. What you then need is to re-select the text portion again, which might take quite a long time, if you deal with large files. Hitting<code>gv</code>in command mode, takes that work from you and selects the last visual selection again.</p>
<h3>Grep within VIM</h3>
<p>Refactoring happens quite often in dynamic projects. &#8220;Real&#8221; IDE&#8217;s offer a lot of tools for this task. While VIM does not, you can enhance your refactoring process a lot with using regex and this tiny tip: To grep through a lot of files for certain strings and then perform changes on each occurrence, vim offers the<code>:grep command</code>.<code>:grep &lt;string&gt; &lt;files&gt;</code>and VIM will store the list of changes for you and :cn will take you to the next occurance of your string. The :grep command utilizes your systems instance of grep, or a custom command stored in the grepprg configuration variable. There is also an internal implementation of grep available in VIM, which you can use with<code>:vimgrep /&lt;regex&gt;/&lt;flags&gt; &lt;files&gt;</code>. The benefit of the external implementation is, that you can easily customize the command to use, e.g. if you need to ignore certain directories while grepping recursively (for instance .svn dirs). You can also get a list of all occurrences of your grep command, using :ll, which is actually a feature of VIMs quickfix tool. Simply select the next entry you want to jump to and hit return in the location list.</p>
<h3>Placeholders in commands</h3>
<p>Who doesn&#8217;t know the case, where you need to open a file in the same directory, the currently edited file resides in? Sure, you can simply use<code>:split &lt;file&gt;</code>, but if your current working directory is far away from the edited file, you possibly will have to type a long long path again. VIM offers you, to replace certain placeholders in commands automatically, most important:<code>%</code>is replaced with the actual file name (so,<code>:split %</code>will open a new window editing the current file &#8211; I know that just<code>:split</code>does the same, but it&#8217;s a nice example to show what<code>%</code>does). So, how does this help in the described case? The replacement text can also be modified by certain modifiers, like<code>:h</code>, which removes the last portion of a file path (the file name). For instance if you currently edit<code>/home/dotxp/dev/ez/ezc/trunk/ConsoleTools/src/table.php</code>and want to split to<code>/home/dotxp/dev/ez/ezc/trunk/ConsoleTools/src/output.php</code>you can do this easily using<code>:split %:h/output.php</code>. Another useful modifier is<code>:s?&lt;regex&gt;?&lt;replacement&gt;?</code>, which obviously uses a regex to modify the given path. Unlikely the usual replacement command<code>:s</code>, you need to specify the global modifier<code>g</code>before the regex instead of doing so after it. A short example:<code>:split %:gs?trunk?/releases/1.1/?</code>will split to the file table.php of ConsoleTools release 1.1.</p>
<h3>Emergency help</h3>
<p>Appending an exclamation mark (<code>!</code>) to a command (<code>:<command>!</code>) forces VIM to execute the command, even if it might be dangerous to do so. Quite useless, but still funny is<code>:help!</code>.</p>
<h3>Rewrap my text</h3>
<p>I reached a stage, where do not only edit my source code using VIM, but mainly every other kind of text data (like documentation, todo lists, etc.), because I&#8217;m simply so used to its features. When editing plain text, the automatic wrap features (e.g. textwidth) of VIM are quite useful. In some cases, you might edit text later and therefore destroy a nicely wrapped text block. VIM can easily re-perform the wrapping for you: Select the text block in visual mode (using &lt;SHIFT&gt;+&lt;v&gt;) and hit<code>&lt;g&gt;&lt;q&gt;</code>.</p>
<h3>Uppercase letters</h3>
<p>There are a lot of helpful shortcuts on your keyboard, which you might not know about. Every VIM user should now, that<code>&lt;d&gt;</code>deletes something,<code>&lt;y&gt;</code>(yank) copies something and<code>&lt;c&gt;</code>changes something (delete and start inserting) in VIM (all in command mode). Furthermore, most people know that e.g.<code>&lt;d&gt;&lt;w&gt;</code>deletes the next word, etc.. What I did not know for a long time was, that<code>&lt;D&gt;</code>, &lt;Y&#038;gt</code>; and<code>&lt;C&gt;</code>are shortcuts to perform the desired operation until the end of the current line. For instance, simply type<code>&lt;C&gt;</code>to change the contents of the current line from your cursors position on.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2006/10/comfortable-editing-with-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Expresiones regulares en MySQL</title>
		<link>http://blog.calcifer.com.ar/2006/09/expresiones-regulares-en-mysql/</link>
		<comments>http://blog.calcifer.com.ar/2006/09/expresiones-regulares-en-mysql/#comments</comments>
		<pubDate>Sat, 30 Sep 2006 16:10:58 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2006/09/30/expresiones-regulares-en-mysql/</guid>
		<description><![CDATA[En MySQL pueden usarse expresiones regulares mediante el operador
REGEXP
:
^
Comienzo de una cadena.

mysql&#62; SELECT 'fo\nfo' REGEXP '^fo$'; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; -&#62; 0
mysql&#62; SELECT 'fofo' REGEXP '^fo'; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;-&#62; 1

$
Final de una cadena.

mysql&#62; SELECT 'fo\no' REGEXP '^fo\no$'; &#160; &#160; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>En MySQL pueden usarse expresiones regulares mediante el operador</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">REGEXP</div></div>
<p>:</p>
<h3 class="margin20 pink">^</h3>
<p class="margin5">Comienzo de una cadena.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'fo\nfo' REGEXP '^fo$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 0<br />
mysql&gt; SELECT 'fofo' REGEXP '^fo'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1</div></div>
</pre>
<h3 class="margin20 pink">$</h3>
<p class="margin5">Final de una cadena.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'fo\no' REGEXP '^fo\no$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1<br />
mysql&gt; SELECT 'fo\no' REGEXP '^fo$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 0</div></div>
</pre>
<h3 class="pink margin20">.</h3>
<p class="margin5">Cualquier caracter (incluído <a href="/2006/08/18/caracteres-de-salto-de-linea/" title="Caracteres de salto de línea" target="_blank">line feed y carriage return</a>).</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'fofo' REGEXP '^f.*$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1<br />
mysql&gt; SELECT 'fo\r\nfo' REGEXP '^f.*$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1</div></div>
</pre>
<p><span id="more-57"></span></p>
<h3 class="pink margin20">a*</h3>
<p class="margin5">Secuencia de cero o más caracteres.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'Ban' REGEXP '^Ba*n'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1<br />
mysql&gt; SELECT 'Baaan' REGEXP '^Ba*n'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1<br />
mysql&gt; SELECT 'Bn' REGEXP '^Ba*n'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1</div></div>
</pre>
<h3 class="pink margin20">a+</h3>
<p class="margin5">Secuencia de uno o más caracteres.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'Ban' REGEXP '^Ba+n'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1<br />
mysql&gt; SELECT 'Bn' REGEXP '^Ba+n'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 0</div></div>
</pre>
<h3 class="pink margin20">a?</h3>
<p class="margin5">Cero o un caracter.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'Bn' REGEXP '^Ba?n'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1<br />
mysql&gt; SELECT 'Ban' REGEXP '^Ba?n'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1<br />
mysql&gt; SELECT 'Baan' REGEXP '^Ba?n'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 0</div></div>
</pre>
<h3 class="pink margin20">de|abc</h3>
<p class="margin5">Operador lógico OR. Cualquiera de las secuencias &#8216;de&#8217; o &#8216;abc&#8217;.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'pi' REGEXP 'pi|apa'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1<br />
mysql&gt; SELECT 'axe' REGEXP 'pi|apa'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 0<br />
mysql&gt; SELECT 'apa' REGEXP 'pi|apa'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1<br />
mysql&gt; SELECT 'apa' REGEXP '^(pi|apa)$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1<br />
mysql&gt; SELECT 'pi' REGEXP '^(pi|apa)$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1<br />
mysql&gt; SELECT 'pix' REGEXP '^(pi|apa)$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 0</div></div>
</pre>
<h3 class="pink margin20">(abc)*</h3>
<p class="margin5">Match de una o más instancias de la secuencia &#8216;abc&#8217;.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'pi' REGEXP '^(pi)*$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1<br />
mysql&gt; SELECT 'pip' REGEXP '^(pi)*$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 0<br />
mysql&gt; SELECT 'pipi' REGEXP '^(pi)*$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1</div></div>
</pre>
<h3 class="pink margin20">{1}, {2,3}</h3>
<p class="margin5">La notación</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">{n}</div></div>
<p>o</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">{m,n}</div></div>
<p>provee una forma más general en la cual hacer match de varias ocurrencias del pattern que precede, donde m indica cantidad mínima de ocurrencias y n indica máxima. Ambos valores son enteros.</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">a*</div></div>
<p>Puede escribirse como</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">a{0,}</div></div>
<p>.</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">a+</div></div>
<p>Puede escribirse como</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">a{1,}</div></div>
<p>.</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">a?</div></div>
<p>Puede escribirse como</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">a{0,1}</div></div>
<p>.</p>
<p>Para ser más precisos,</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">a{n}</div></div>
<p>hace match de, exactamente, n instancias de a.</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">a{n,}</div></div>
<p>hace match de n o más instancias de a.</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">a{m,n}</div></div>
<p>hace match de entre m y n instancias de a, donde m y n están incluídos.</p>
<p>m y n deben estar en el rango desde 0 a</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">RE_DUP_MAX</div></div>
<p>(default 255), inclusive. Si se especifican ambos valores (m y n), m debe ser menor o igual a n.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'abcde' REGEXP 'a[bcd]{2}e'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 0<br />
mysql&gt; SELECT 'abcde' REGEXP 'a[bcd]{3}e'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1<br />
mysql&gt; SELECT 'abcde' REGEXP 'a[bcd]{1,10}e'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1</div></div>
</pre>
<h3 class="pink margin20">[a-dX], [^a-dX]</h3>
<p class="margin5">Match de cualquier caracter perteneciente al rango a-dX (a, b, c, d, X) y en el caso que el rango sea precedido por</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">^</div></div>
<p>equivale a cualquier caracter que no corresponda con dicho rango. Por ejemplo,</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">[0-9]</div></div>
<p>hace match de cualquier dígito decimal, mientras que</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">[^0-9]</div></div>
<p>de cualquier caracter no decimal.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'aXbc' REGEXP '[a-dXYZ]'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1<br />
mysql&gt; SELECT 'aXbc' REGEXP '^[a-dXYZ]$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 0<br />
mysql&gt; SELECT 'aXbc' REGEXP '^[a-dXYZ]+$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1<br />
mysql&gt; SELECT 'aXbc' REGEXP '^[^a-dXYZ]+$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 0<br />
mysql&gt; SELECT 'gheis' REGEXP '^[^a-dXYZ]+$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 1<br />
mysql&gt; SELECT 'gheisa' REGEXP '^[^a-dXYZ]+$'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 0</div></div>
</pre>
<h3 class="pink margin20">[.characters.]</h3>
<p class="margin5">Esta expresión permite hacer match de un caracter mediante su nombre, como por ejemplo</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">[.newline.]</div></div>
<p>en lugar de \n. La lista completa puede encontrarse en regexp/cname.h file.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT '~' REGEXP '[[.~.]]'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1<br />
mysql&gt; SELECT '~' REGEXP '[[.tilde.]]'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1</div></div>
</pre>
<h3 class="pink margin20">[:character_class:]</h3>
<p class="margin5">MySQL, como tantos otros lenguajes que implementan expresiones regulares, incluye una serie de alias para denominar clases de caracteres. La siguiente tabla es una lista de las clases y sus nombres.</p>
<table class="table1">
<tr>
<td>alnum</td>
<td>Alphanumeric characters</td>
</tr>
<tr>
<td>alpha</td>
<td>Alphabetic characters</td>
</tr>
<tr>
<td>blank</td>
<td>Whitespace characters</td>
</tr>
<tr>
<td>cntrl</td>
<td>Control characters</td>
</tr>
<tr>
<td>digit</td>
<td>Digit characters</td>
</tr>
<tr>
<td>graph</td>
<td>Graphic characters</td>
</tr>
<tr>
<td>lower</td>
<td>Lowercase alphabetic characters</td>
</tr>
<tr>
<td>print</td>
<td>Graphic or space characters</td>
</tr>
<tr>
<td>punct</td>
<td>Punctuation characters</td>
</tr>
<tr>
<td>space</td>
<td>Space, tab, newline, and carriage return</td>
</tr>
<tr>
<td>upper</td>
<td>Uppercase alphabetic characters</td>
</tr>
<tr>
<td>xdigit</td>
<td>Hexadecimal digit characters</td>
</tr>
</table>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'justalnums' REGEXP '[[:alnum:]]+'; &nbsp; &nbsp; &nbsp; -&gt; 1<br />
mysql&gt; SELECT '!!' REGEXP '[[:alnum:]]+'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 0</div></div>
</pre>
<h3 class="pink margin20">[[:<:]], [[:>:]]</h3>
<p class="margin5">Estos marcadores son usados para marcar límites de palabras. Ellos hacen match del comienzo y final de una palabra, respectivamente. Una palabra es una secuencia de caracteres pertenecientes a la clase</p>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">alnum</div></div>
<p>(alphanumeric) y al caracter underscore (_). La definición de palabra dice también que dicha secuencia no debe ser precedida o seguida de ningún caracter de los mencionados.</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT 'a word a' REGEXP '[[:&lt;:]]word[[:&gt;:]]'; &nbsp; -&gt; 1<br />
mysql&gt; SELECT 'a xword a' REGEXP '[[:&lt;:]]word[[:&gt;:]]'; &nbsp;-&gt; 0</div></div>
</pre>
<h3 class="pink margin20">\</h3>
<p class="margin5">Para hacer que los caracteres especiales pierdan su significado deben ser precedidos por dos backslash (\). El analizador de MySQL interpreta uno de los \ y la librería de expresiones regulares el otro. Por ejemplo, para hacer un match de la cadena &#8216;1+2&#8242; la cual contiene el caracter especial +, sólo la última expresión regular es correcta:</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&gt; SELECT '1+2' REGEXP '1+2'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 0<br />
mysql&gt; SELECT '1+2' REGEXP '1\+2'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; 0<br />
mysql&gt; SELECT '1+2' REGEXP '1\\+2'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt; 1</div></div>
</pre>
<h3 class="pink margin20">=0, =1</h3>
<p class="margin5">Invertir el match de una regex es tan simple como comparar el resultado con 1 o 0. En el ejemplo se muestra primero el resultado de una consulta simple, luego sólo los registros que contengan el caracter &#8216;5&#8242; y finalmente se invierte el filtro. También funciona con true y false</p>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&amp;gt; SELECT link_url FROM wp_links;<br />
+------------------------------+<br />
| link_url &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />
+------------------------------+<br />
| http://barrapunto.com &nbsp; &nbsp; &nbsp; &nbsp;|<br />
| http://www.microsiervos.com/ |<br />
| http://www.kriptopolis.org/ &nbsp;|<br />
| http://meneame.net/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
| http://www.error500.net/ &nbsp; &nbsp; |<br />
| http://slashdot.org &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
| http://astroseti.org/ &nbsp; &nbsp; &nbsp; &nbsp;|<br />
+------------------------------+</div></div>
</pre>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&amp;gt; SELECT link_url FROM wp_links WHERE link_url REGEXP '5';<br />
+--------------------------+<br />
| link_url &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />
+--------------------------+<br />
| http://www.error500.net/ |<br />
+--------------------------+</div></div>
</pre>
<pre>
<div class="codecolorer-container text " style="overflow:auto;white-space:nowrap;width:435px"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">mysql&amp;gt; SELECT link_url FROM wp_links WHERE link_url REGEXP '5'=0;<br />
+------------------------------+<br />
| link_url &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />
+------------------------------+<br />
| http://barrapunto.com &nbsp; &nbsp; &nbsp; &nbsp;|<br />
| http://www.microsiervos.com/ |<br />
| http://www.kriptopolis.org/ &nbsp;|<br />
| http://meneame.net/ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
| http://slashdot.org &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />
| http://astroseti.org/ &nbsp; &nbsp; &nbsp; &nbsp;|<br />
+------------------------------+</div></div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2006/09/expresiones-regulares-en-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Función capitalize</title>
		<link>http://blog.calcifer.com.ar/2006/08/funcion-capitalize/</link>
		<comments>http://blog.calcifer.com.ar/2006/08/funcion-capitalize/#comments</comments>
		<pubDate>Sat, 26 Aug 2006 14:31:50 +0000</pubDate>
		<dc:creator>lvidarte</dc:creator>
				<category><![CDATA[None]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[snippets]]></category>

		<guid isPermaLink="false">http://blog.calcifer.com.ar/2006/08/26/anadir-metodos-a-objetos-de-javascript/</guid>
		<description><![CDATA[Función capitalize en JavaScript, creada por Jonas Raoni Soares Silva. He cambiado la regex original/\w+/gpor/\S+/gpara que funcione con acentos.
123456789myText = &#34;hElLo wORlD&#34;;

String.prototype.capitalize = function&#40;&#41; &#123;
&#160; &#160; return this.replace&#40;/\S+/g, function&#40;a&#41; &#123;
&#160; &#160; &#160; &#160; return a.charAt&#40;0&#41;.toUpperCase&#40;&#41; + a.substr&#40;1&#41;.toLowerCase&#40;&#41;;
&#160; &#160; &#125;&#41;;
&#125;;

document.write&#40; myText.capitalize&#40;&#41; &#41;;
]]></description>
			<content:encoded><![CDATA[<p>Función capitalize en JavaScript, creada por <a href="http://www.joninhas.ath.cx" class="external">Jonas Raoni Soares Silva</a>. He cambiado la regex original<code>/\w+/g</code>por<code>/\S+/g</code>para que funcione con acentos.</p>
<div class="codecolorer-container javascript " style="overflow:auto;white-space:nowrap;width:435px"><table cellspacing="0" cellpadding="0"><tbody><tr><td class="line-numbers"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="javascript codecolorer" style="font-family:Monaco,Lucida Console,monospace">myText <span class="sy0">=</span> <span class="st0">&quot;hElLo wORlD&quot;</span><span class="sy0">;</span><br />
<br />
String.<span class="me1">prototype</span>.<span class="me1">capitalize</span> <span class="sy0">=</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">return</span> <span class="kw1">this</span>.<span class="me1">replace</span><span class="br0">&#40;</span><span class="co2">/\S+/g</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>a<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> a.<span class="me1">charAt</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>.<span class="me1">toUpperCase</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">+</span> a.<span class="me1">substr</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span>.<span class="me1">toLowerCase</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><span class="sy0">;</span><br />
<br />
document.<span class="kw1">write</span><span class="br0">&#40;</span> myText.<span class="me1">capitalize</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><span class="sy0">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.calcifer.com.ar/2006/08/funcion-capitalize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

