<?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>just_add_watir &#124; Advanced recipes for Watir &#187; regex</title>
	<atom:link href="http://justaddwatir.com/tag/regex/feed/" rel="self" type="application/rss+xml" />
	<link>http://justaddwatir.com</link>
	<description>Advanced recipes for Watir</description>
	<lastBuildDate>Wed, 21 Oct 2009 02:44:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Q. How do I attach to a current IE session?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-attach-to-a-current-ie-session/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-attach-to-a-current-ie-session/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 12:53:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[.attach]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=43</guid>
		<description><![CDATA[A. Use the .attach method...
Example watir:

@b=Watir::IE.attach&#40;:title,//&#41;

I have used regex here for the window title, you can be more specific if you like.
]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use the .attach method...</strong><br />
Example watir:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#0066ff; font-weight:bold;">@b</span>=<span style="color:#6666ff; font-weight:bold;">Watir::IE</span>.<span style="color:#9900CC;">attach</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:title</span>,<span style="color:#006600; font-weight:bold;">//</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>I have used regex here for the window title, you can be more specific if you like.</p>
]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-attach-to-a-current-ie-session/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Q. How do I set a checkbox with a dynamic id attribute?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-set-a-checkbox-with-a-dynamic-id-attribute/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-set-a-checkbox-with-a-dynamic-id-attribute/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 03:59:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[.checkbox]]></category>
		<category><![CDATA[.gsub]]></category>
		<category><![CDATA[.html]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=40</guid>
		<description><![CDATA[A. Use a regex match  to populate a dynamic variable ...
Example html:

&#60;form action=&#34;test_0019.html&#34; method=&#34;get&#34; accept-charset=&#34;utf-8&#34;&#62;
&#60;input id=&#34;cblRoles_3&#34; type=&#34;checkbox&#34; tabindex=&#34;47&#34; name=&#34;cblRoles:3&#34;/&#62;
&#60;label for=&#34;cblRoles_3&#34;&#62;Customer&#60;/label&#62;
&#60;input id=&#34;cblRoles_4&#34; type=&#34;checkbox&#34; tabindex=&#34;48&#34; name=&#34;cblRoles:4&#34;/&#62;
&#60;label for=&#34;cblRoles_4&#34;&#62;Expedite&#60;/label&#62;

Example watir:

dynamic_id = @b.html&#91;/cblRoles_\d+&#62;Expedite/&#93;.gsub&#40;&#34;&#62;Expedite&#34;,&#34;&#34;&#41;
@b.checkbox&#40;:id,dynamic_id&#41;.set

]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use a regex match  to populate a dynamic variable ...</strong><br />
<a href="http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0019.html">Example html</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;test_0019.html&quot;</span> <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;get&quot;</span> <span style="color: #000066;">accept-charset</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;utf-8&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cblRoles_3&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;47&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cblRoles:3&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cblRoles_3&quot;</span>&gt;</span>Customer<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cblRoles_4&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;48&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cblRoles:4&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span> <span style="color: #000066;">for</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cblRoles_4&quot;</span>&gt;</span>Expedite<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span></pre></div></div>

<p>Example watir:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">dynamic_id = <span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">html</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">/</span>cblRoles_\d<span style="color:#006600; font-weight:bold;">+&gt;</span>Expedite<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;&gt;Expedite&quot;</span>,<span style="color:#996600;">&quot;&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">checkbox</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:id</span>,dynamic_id<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">set</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-set-a-checkbox-with-a-dynamic-id-attribute/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Q. What&#039;s with the /i in Ruby regular expressions?</title>
		<link>http://justaddwatir.com/2008/q-whats-with-the-i-in-ruby-regular-expressions/</link>
		<comments>http://justaddwatir.com/2008/q-whats-with-the-i-in-ruby-regular-expressions/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 11:04:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=13</guid>
		<description><![CDATA[A. the /i indicates an ignore case modifier ... 
In Ruby, a regular expression is written in the form of /pattern/modifiers where "pattern" is the regular expression itself, and "modifiers" are a series of characters indicating various options.
Ruby supports the following modifiers:
    * /i makes the regex match case insensitive.
   [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A. the /i indicates an ignore case modifier ... </strong><br />
In Ruby, a regular expression is written in the form of /pattern/modifiers where "pattern" is the regular expression itself, and "modifiers" are a series of characters indicating various options.<br />
Ruby supports the following modifiers:<br />
    * /i makes the regex match case insensitive.<br />
    * /m makes the dot match newlines. Ruby indeed uses /m, whereas Perl and<br />
many other programming languages use /s for "dot matches newlines".<br />
    * /x tells Ruby to ignore whitespace between regex tokens.<br />
    * /o causes any #{...} substitutions in a particular regex literal to be performed just once, the first time it is evaluated. Otherwise, the substitutions will be performed every time the literal generates a Regexp object.<br />
You can combine multiple modifiers by stringing them together as in /regex/is.<br />
See more information here: http://www.regular-expressions.info/ruby.html</p>
]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-whats-with-the-i-in-ruby-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Q. How do I get text from a browser?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-get-text-from-a-browser/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-get-text-from-a-browser/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 04:23:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[.text]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=7</guid>
		<description><![CDATA[A. Use a regex match on the .text method ...
Example html:

&#60;p&#62;
  The Employee Code assigned is 10000671
&#60;/p&#62;

Example watir:

puts /&#40;1\d+&#41;/.match&#40;@b.text&#41;

]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use a regex match on the .text method ...</strong><br />
<a href="http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0006.html">Example html</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
  The Employee Code assigned is 10000671
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></pre></div></div>

<p>Example watir:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">1</span>\d<span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">match</span><span style="color:#006600; font-weight:bold;">&#40;</span>@b.<span style="color:#9900CC;">text</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-get-text-from-a-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Q. How do I check if text exists in browser?</title>
		<link>http://justaddwatir.com/2008/q-how-do-i-check-if-text-exists-in-browser/</link>
		<comments>http://justaddwatir.com/2008/q-how-do-i-check-if-text-exists-in-browser/#comments</comments>
		<pubDate>Fri, 18 Jul 2008 03:43:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[watir]]></category>
		<category><![CDATA[.include]]></category>
		<category><![CDATA[.text]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://justaddwatir.com/watir/?p=6</guid>
		<description><![CDATA[A. Use the .include? method or a regular expression ...
Example html:

&#60;p&#62;
  watir does not go well with furry little animals
&#60;/p&#62;

Example watir:

puts &#34;Text 'watir' DOES exist&#34; if @b.text.include? 'watir'
puts &#34;Text 'regex' DOES NOT exist&#34; unless @b.text =~ /regex/
puts &#34;Text 'furry little animals' DOES exist&#34; if @b.text.include? 'furry little animals'
puts &#34;Text 'furry animals' DOES NOT exist&#34; [...]]]></description>
			<content:encoded><![CDATA[<p><strong>A. Use the .include? method or a regular expression ...</strong><br />
<a href="http://justaddwatir.com/watir/test_html/tc_0001_0100/test_0005.html">Example html</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
  watir does not go well with furry little animals
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span></pre></div></div>

<p>Example watir:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Text 'watir' DOES exist&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">text</span>.<span style="color:#9966CC; font-weight:bold;">include</span>? <span style="color:#996600;">'watir'</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Text 'regex' DOES NOT exist&quot;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">text</span> =~ <span style="color:#006600; font-weight:bold;">/</span>regex<span style="color:#006600; font-weight:bold;">/</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Text 'furry little animals' DOES exist&quot;</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">text</span>.<span style="color:#9966CC; font-weight:bold;">include</span>? <span style="color:#996600;">'furry little animals'</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Text 'furry animals' DOES NOT exist&quot;</span> <span style="color:#9966CC; font-weight:bold;">unless</span> <span style="color:#0066ff; font-weight:bold;">@b</span>.<span style="color:#9900CC;">text</span>.<span style="color:#9966CC; font-weight:bold;">include</span>? <span style="color:#996600;">'furry animals'</span></pre></div></div>

<p>Any character(s) placed between the apostrophe's will be searched for. The response will return <strong>true</strong> if found, and <strong>false</strong> if not found.</p>
]]></content:encoded>
			<wfw:commentRss>http://justaddwatir.com/2008/q-how-do-i-check-if-text-exists-in-browser/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
