<?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>Stanley Shilov - Web Development, SEO and SEM &#187; madlib</title>
	<atom:link href="http://www.stanleyshilov.com/blog/tag/madlib/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stanleyshilov.com</link>
	<description>Web Development with a twist of Affiliate Marketing</description>
	<lastBuildDate>Sun, 06 Jun 2010 21:11:54 +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>Java Mad Libs function</title>
		<link>http://www.stanleyshilov.com/blog/java-mad-libs-function/</link>
		<comments>http://www.stanleyshilov.com/blog/java-mad-libs-function/#comments</comments>
		<pubDate>Sat, 26 Sep 2009 17:21:48 +0000</pubDate>
		<dc:creator>Stanley</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[content generation]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[madlib]]></category>

		<guid isPermaLink="false">http://www.stanleyshilov.com/?p=284</guid>
		<description><![CDATA[This madlibs Java function finds keyword combinations contained in {curly brackets} and randomly selects one of the keywords.
Ex: This {string&#124;sentence&#124;bit of text} will be different every time you {run&#124;execute} the {function&#124;method&#124;Mad Lib function&#124;madlib method}

// Madlib function:
public static String madlib(String content){
	Pattern regex = Pattern.compile(&#34;\\{(.*?)\\}&#34;);
	Matcher matches = regex.matcher(content);

	String[] madlibArray = null;

	while(matches.find()){
		madlibArray = matches.group(1).split(&#34;\\&#124;&#34;);
		content = content.replace(&#34;{&#34; + matches.group(1) [...]]]></description>
			<content:encoded><![CDATA[<p>This <a href="http://www.stanleyshilov.com/blog/code-java-mad-libs-function/">madlibs Java function</a> finds keyword combinations contained in {curly brackets} and randomly selects one of the keywords.</p>
<p><strong>Ex:</strong> This {string|sentence|bit of text} will be different every time you {run|execute} the {function|method|Mad Lib function|madlib method}</p>
<pre class="brush: java;">
// Madlib function:
public static String madlib(String content){
	Pattern regex = Pattern.compile(&quot;\\{(.*?)\\}&quot;);
	Matcher matches = regex.matcher(content);

	String[] madlibArray = null;

	while(matches.find()){
		madlibArray = matches.group(1).split(&quot;\\|&quot;);
		content = content.replace(&quot;{&quot; + matches.group(1) + &quot;}&quot;, madlibArray[(int) (Math.random() * madlibArray.length)]);
	}
	return content;
}
</pre>
<p>If you have any suggestions on how to improve this method, leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stanleyshilov.com/blog/java-mad-libs-function/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
