<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rapodraza</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Rapodraza"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Rapodraza"/>
	<updated>2026-08-20T16:47:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rapodraz&amp;diff=12892</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rapodraz</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rapodraz&amp;diff=12892"/>
		<updated>2008-06-10T14:53:47Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /is/&lt;br /&gt;
  &amp;gt;&amp;gt; 2&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
  /is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
  /hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
  String str = &amp;quot;This is a string&amp;quot;;&lt;br /&gt;
  str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false.&lt;br /&gt;
  str.matches(&amp;quot;.*is.*&amp;quot;); // will return true&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
  String myString = new String(&amp;quot;This is a string&amp;quot;);&lt;br /&gt;
  Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;);&lt;br /&gt;
  Matcher myMatcher = myPattern.matcher(myString);&lt;br /&gt;
  Vector results = new Vector(); // to store the resulting matches&amp;lt;br&amp;gt;&lt;br /&gt;
  while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found&lt;br /&gt;
    results.add(myMatcher.group()); // group() returns the matched string&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
http://www.regular-expressions.info/ruby.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.regular-expressions.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html?page=3&amp;lt;br&amp;gt;&lt;br /&gt;
http://regex.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.blueskyonmars.com/2003/10/31/14-stringmatches-is-dumb/&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/core/classes/MatchData.html&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=12891</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=12891"/>
		<updated>2008-06-10T12:22:01Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /is/&lt;br /&gt;
  &amp;gt;&amp;gt; 2&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
  /is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
  /hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
  String str = &amp;quot;This is a string&amp;quot;;&lt;br /&gt;
  str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false.&lt;br /&gt;
  str.matches(&amp;quot;.*is.*&amp;quot;); // will return true&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
  String myString = new String(&amp;quot;This is a string&amp;quot;);&lt;br /&gt;
  Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;);&lt;br /&gt;
  Matcher myMatcher = myPattern.matcher(myString);&lt;br /&gt;
  Vector results = new Vector(); // to store the resulting matches&amp;lt;br&amp;gt;&lt;br /&gt;
  while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found&lt;br /&gt;
    results.add(myMatcher.group()); // group() returns the matched string&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
http://www.regular-expressions.info/ruby.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.regular-expressions.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html?page=3&amp;lt;br&amp;gt;&lt;br /&gt;
http://regex.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.blueskyonmars.com/2003/10/31/14-stringmatches-is-dumb/&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/core/classes/MatchData.html&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=12890</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=12890"/>
		<updated>2008-06-10T12:21:43Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code. hello hy&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /is/&lt;br /&gt;
  &amp;gt;&amp;gt; 2&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
  /is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
  /hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
  String str = &amp;quot;This is a string&amp;quot;;&lt;br /&gt;
  str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false.&lt;br /&gt;
  str.matches(&amp;quot;.*is.*&amp;quot;); // will return true&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
  String myString = new String(&amp;quot;This is a string&amp;quot;);&lt;br /&gt;
  Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;);&lt;br /&gt;
  Matcher myMatcher = myPattern.matcher(myString);&lt;br /&gt;
  Vector results = new Vector(); // to store the resulting matches&amp;lt;br&amp;gt;&lt;br /&gt;
  while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found&lt;br /&gt;
    results.add(myMatcher.group()); // group() returns the matched string&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
http://www.regular-expressions.info/ruby.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.regular-expressions.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html?page=3&amp;lt;br&amp;gt;&lt;br /&gt;
http://regex.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.blueskyonmars.com/2003/10/31/14-stringmatches-is-dumb/&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/core/classes/MatchData.html&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=12889</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=12889"/>
		<updated>2008-06-10T12:21:27Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code. hello&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /is/&lt;br /&gt;
  &amp;gt;&amp;gt; 2&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
  /is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
  /hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
  String str = &amp;quot;This is a string&amp;quot;;&lt;br /&gt;
  str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false.&lt;br /&gt;
  str.matches(&amp;quot;.*is.*&amp;quot;); // will return true&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
  String myString = new String(&amp;quot;This is a string&amp;quot;);&lt;br /&gt;
  Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;);&lt;br /&gt;
  Matcher myMatcher = myPattern.matcher(myString);&lt;br /&gt;
  Vector results = new Vector(); // to store the resulting matches&amp;lt;br&amp;gt;&lt;br /&gt;
  while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found&lt;br /&gt;
    results.add(myMatcher.group()); // group() returns the matched string&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
http://www.regular-expressions.info/ruby.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.regular-expressions.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html?page=3&amp;lt;br&amp;gt;&lt;br /&gt;
http://regex.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.blueskyonmars.com/2003/10/31/14-stringmatches-is-dumb/&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/core/classes/MatchData.html&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=12888</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=12888"/>
		<updated>2008-06-10T12:20:39Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /is/&lt;br /&gt;
  &amp;gt;&amp;gt; 2&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
  /is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
  /hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
  String str = &amp;quot;This is a string&amp;quot;;&lt;br /&gt;
  str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false.&lt;br /&gt;
  str.matches(&amp;quot;.*is.*&amp;quot;); // will return true&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
  String myString = new String(&amp;quot;This is a string&amp;quot;);&lt;br /&gt;
  Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;);&lt;br /&gt;
  Matcher myMatcher = myPattern.matcher(myString);&lt;br /&gt;
  Vector results = new Vector(); // to store the resulting matches&amp;lt;br&amp;gt;&lt;br /&gt;
  while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found&lt;br /&gt;
    results.add(myMatcher.group()); // group() returns the matched string&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
http://www.regular-expressions.info/ruby.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.regular-expressions.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html?page=3&amp;lt;br&amp;gt;&lt;br /&gt;
http://regex.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.blueskyonmars.com/2003/10/31/14-stringmatches-is-dumb/&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/core/classes/MatchData.html&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=12887</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=12887"/>
		<updated>2008-06-10T12:20:18Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /is/ &lt;br /&gt;
  &amp;gt;&amp;gt; 2&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
  /is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
  /hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
  String str = &amp;quot;This is a string&amp;quot;;&lt;br /&gt;
  str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false.&lt;br /&gt;
  str.matches(&amp;quot;.*is.*&amp;quot;); // will return true&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
  String myString = new String(&amp;quot;This is a string&amp;quot;);&lt;br /&gt;
  Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;);&lt;br /&gt;
  Matcher myMatcher = myPattern.matcher(myString);&lt;br /&gt;
  Vector results = new Vector(); // to store the resulting matches&amp;lt;br&amp;gt;&lt;br /&gt;
  while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found&lt;br /&gt;
    results.add(myMatcher.group()); // group() returns the matched string&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
http://www.regular-expressions.info/ruby.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.regular-expressions.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html?page=3&amp;lt;br&amp;gt;&lt;br /&gt;
http://regex.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.blueskyonmars.com/2003/10/31/14-stringmatches-is-dumb/&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/core/classes/MatchData.html&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11732</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11732"/>
		<updated>2008-06-02T13:53:29Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /is/&lt;br /&gt;
  &amp;gt;&amp;gt; 2&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
  /is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
  /hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
  String str = &amp;quot;This is a string&amp;quot;;&lt;br /&gt;
  str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false.&lt;br /&gt;
  str.matches(&amp;quot;.*is.*&amp;quot;); // will return true&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
  String myString = new String(&amp;quot;This is a string&amp;quot;);&lt;br /&gt;
  Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;);&lt;br /&gt;
  Matcher myMatcher = myPattern.matcher(myString);&lt;br /&gt;
  Vector results = new Vector(); // to store the resulting matches&amp;lt;br&amp;gt;&lt;br /&gt;
  while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found&lt;br /&gt;
    results.add(myMatcher.group()); // group() returns the matched string&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
http://www.regular-expressions.info/ruby.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.regular-expressions.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html?page=3&amp;lt;br&amp;gt;&lt;br /&gt;
http://regex.info/java.html&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.blueskyonmars.com/2003/10/31/14-stringmatches-is-dumb/&amp;lt;br&amp;gt;&lt;br /&gt;
http://www.ruby-doc.org/core/classes/MatchData.html&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11731</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11731"/>
		<updated>2008-06-02T13:52:55Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /is/&lt;br /&gt;
  &amp;gt;&amp;gt; 2&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
  /is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
  /hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
  String str = &amp;quot;This is a string&amp;quot;;&lt;br /&gt;
  str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false.&lt;br /&gt;
  str.matches(&amp;quot;.*is.*&amp;quot;); // will return true&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
  String myString = new String(&amp;quot;This is a string&amp;quot;);&lt;br /&gt;
  Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;);&lt;br /&gt;
  Matcher myMatcher = myPattern.matcher(myString);&lt;br /&gt;
  Vector results = new Vector(); // to store the resulting matches&amp;lt;br&amp;gt;&lt;br /&gt;
  while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found&lt;br /&gt;
    results.add(myMatcher.group()); // group() returns the matched string&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
http://www.regular-expressions.info/ruby.html&lt;br /&gt;
http://www.regular-expressions.info/java.html&lt;br /&gt;
http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html?page=3&lt;br /&gt;
http://regex.info/java.html&lt;br /&gt;
http://www.blueskyonmars.com/2003/10/31/14-stringmatches-is-dumb/&lt;br /&gt;
http://www.ruby-doc.org/core/classes/MatchData.html&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11730</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11730"/>
		<updated>2008-06-02T13:51:44Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /is/&lt;br /&gt;
  &amp;gt;&amp;gt; 2&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
  /is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
  /hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
  String str = &amp;quot;This is a string&amp;quot;;&lt;br /&gt;
  str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false.&lt;br /&gt;
  str.matches(&amp;quot;.*is.*&amp;quot;); // will return true&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
  String myString = new String(&amp;quot;This is a string&amp;quot;);&lt;br /&gt;
  Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;);&lt;br /&gt;
  Matcher myMatcher = myPattern.matcher(myString);&lt;br /&gt;
  Vector results = new Vector(); // to store the resulting matches&amp;lt;br&amp;gt;&lt;br /&gt;
  while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found&lt;br /&gt;
    results.add(myMatcher.group()); // group() returns the matched string&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
=Links=&lt;br /&gt;
[http://www.regular-expressions.info/ruby.html]&lt;br /&gt;
[http://www.regular-expressions.info/java.html]&lt;br /&gt;
[http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-regex.html?page=3]&lt;br /&gt;
[http://regex.info/java.html]&lt;br /&gt;
[http://www.blueskyonmars.com/2003/10/31/14-stringmatches-is-dumb/]&lt;br /&gt;
[http://www.ruby-doc.org/core/classes/MatchData.html]&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11729</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11729"/>
		<updated>2008-06-02T13:49:13Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /is/&lt;br /&gt;
  &amp;gt;&amp;gt; 2&lt;br /&gt;
  &amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
  /is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
  /hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
  &amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
  String str = &amp;quot;This is a string&amp;quot;;&lt;br /&gt;
  str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false.&lt;br /&gt;
  str.matches(&amp;quot;.*is.*&amp;quot;); // will return true&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
  matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
  &amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
  String myString = new String(&amp;quot;This is a string&amp;quot;);&lt;br /&gt;
  Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;);&lt;br /&gt;
  Matcher myMatcher = myPattern.matcher(myString);&lt;br /&gt;
  Vector results = new Vector(); // to store the resulting matches&amp;lt;br&amp;gt;&lt;br /&gt;
  while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found&lt;br /&gt;
    results.add(myMatcher.group()); // group() returns the matched string&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11728</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11728"/>
		<updated>2008-06-02T13:45:11Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;This is a string&amp;quot; =~ /is/ &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; 2 &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;This is a string&amp;quot; =~ /hello/ &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; nil &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
/is/.match(&amp;quot;This is a string&amp;quot;) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
/hello/.match(&amp;quot;This is a string&amp;quot;) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; nil &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
String str = &amp;quot;This is a string&amp;quot;; &amp;lt;br&amp;gt;&lt;br /&gt;
str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false. &amp;lt;br&amp;gt;&lt;br /&gt;
str.matches(&amp;quot;.*is.*&amp;quot;); // will return true &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
matches = &amp;quot;This is a string&amp;quot;.scan(/is/) &amp;lt;br&amp;gt; &lt;br /&gt;
&amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;] &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;] &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Java, it is a bit more complicated. There are no shortcut methods as part of the String class to help us do what we want, and we need to make use of the Pattern and Matcher classes.&lt;br /&gt;
&lt;br /&gt;
String myString = new String(&amp;quot;This is a string); &amp;lt;br&amp;gt;&lt;br /&gt;
Pattern myPattern = Pattern.compile(&amp;quot;is&amp;quot;); &amp;lt;br&amp;gt;&lt;br /&gt;
Matcher myMatcher = myPattern.matcher(myString); &amp;lt;br&amp;gt;&lt;br /&gt;
Vector results = new Vector(); // to store the resulting matches &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
while (myMatcher.find()) { // find() finds the next match, evaluates to false if not found &amp;lt;br&amp;gt;&lt;br /&gt;
  results.add(myMatcher.group()); // group() returns the matched string &amp;lt;br&amp;gt;&lt;br /&gt;
} &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11544</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11544"/>
		<updated>2008-05-30T18:37:49Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;This is a string&amp;quot; =~ /is/ &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; 2 &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;This is a string&amp;quot; =~ /hello/ &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; nil &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
/is/.match(&amp;quot;This is a string&amp;quot;) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
/hello/.match(&amp;quot;This is a string&amp;quot;) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; nil &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
String str = &amp;quot;This is a string&amp;quot;; &amp;lt;br&amp;gt;&lt;br /&gt;
str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false. &amp;lt;br&amp;gt;&lt;br /&gt;
str.matches(&amp;quot;.*is.*&amp;quot;); // will return true &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
In Ruby, a simple way to collect regular expression matches from a String is to use the String.scan() method, which takes a regular expression as a parameter, and returns a String array.&lt;br /&gt;
&lt;br /&gt;
matches = &amp;quot;This is a string&amp;quot;.scan(/is/)&lt;br /&gt;
&amp;gt;&amp;gt; [&amp;quot;is&amp;quot;, &amp;quot;is&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
A slightly more complex regular expression:&lt;br /&gt;
&lt;br /&gt;
matches = &amp;quot;This is a string&amp;quot;.scan(/\w*i\w*/) # match any word with an i in it&lt;br /&gt;
&amp;gt;&amp;gt; [&amp;quot;This&amp;quot;, &amp;quot;is&amp;quot;, &amp;quot;string&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
In Java, &lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11527</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11527"/>
		<updated>2008-05-30T14:05:57Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Regular Expressions in Ruby vs. Java=&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
==General Differences==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
==Code Example: find a regular expression match within a String==&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;This is a string&amp;quot; =~ /is/ &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; 2 &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;quot;This is a string&amp;quot; =~ /hello/ &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; nil &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
/is/.match(&amp;quot;This is a string&amp;quot;) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
/hello/.match(&amp;quot;This is a string&amp;quot;) &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; nil &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Java, it is possible to do a simple version of this using only the String.matches() method, however this is a boolean method so we will miss out on the extra index information that Ruby's  =~ will give.&lt;br /&gt;
 &lt;br /&gt;
String str = &amp;quot;This is a string&amp;quot;; &amp;lt;br&amp;gt;&lt;br /&gt;
str.matches(&amp;quot;is&amp;quot;); // does not do what you expect. This will return false. &amp;lt;br&amp;gt;&lt;br /&gt;
str.matches(&amp;quot;.*is.*&amp;quot;); // will return true &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above code, it is important to realize that matches() will only return true if the entire string from beginning to end is a match. In other words, it behaves as if the input regular expression &amp;quot;regexp&amp;quot; is actually &amp;quot;^regexp$&amp;quot;. For matching a subsring or the entire string, a workaround such as the third line above must be used.&lt;br /&gt;
&lt;br /&gt;
==Code Example: collecting regular expression matches within a String in an array of Strings==&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11526</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11526"/>
		<updated>2008-05-30T12:43:24Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Regular Expressions in Ruby vs. Java =&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for performing equivalent or similar functions more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
== General Differences ==&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
== Code Examples ==&lt;br /&gt;
The following examples will illustrate how Ruby and Java perform the same regular expression task differently.&lt;br /&gt;
&lt;br /&gt;
Find a regular expression match within a string.&lt;br /&gt;
In Ruby, there are 2 simple ways to do this, the main difference between them being that one is a String method and one is a Regexp method. &lt;br /&gt;
First the String method, the [http://www.ruby-doc.org/core/classes/String.html#M000792 =~] operator, which returns the index in the string at which the pattern first matches.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;This is a string&amp;quot; =~ /is/&lt;br /&gt;
&amp;gt;&amp;gt; 2&lt;br /&gt;
&amp;quot;This is a string&amp;quot; =~ /hello/&lt;br /&gt;
&amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
An equivalent way to do this is with the Regexp method match(). Note that match() returns a [http://www.ruby-doc.org/core/classes/MatchData.html MatchData] object if successful.&lt;br /&gt;
&lt;br /&gt;
/is/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
&amp;gt;&amp;gt; #&amp;lt;MatchData:0x5e1715c&amp;gt;&lt;br /&gt;
/hello/.match(&amp;quot;This is a string&amp;quot;)&lt;br /&gt;
&amp;gt;&amp;gt; nil&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11476</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11476"/>
		<updated>2008-05-29T15:35:08Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: /* Regular Expressions in Ruby vs. Java */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Regular Expressions in Ruby vs. Java ==&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for equivalent or similar functions to be performed more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
add code examples&lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11474</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11474"/>
		<updated>2008-05-29T13:27:05Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: /* Regular Expressions in Ruby vs. Java */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Regular Expressions in Ruby vs. Java ==&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for equivalent or similar functions to be performed more simply and with less code.&lt;br /&gt;
&lt;br /&gt;
Ruby can perform most regular expression related functions using a combination of the String and Regexp classes. The String class has several methods that take a Regexp as a parameter, and similarly the Regexp class has methods that take a String as a parameter. Ruby also provides a shorthand for defining regular expressions, a string surrounded by forward slashes: Regexp.new('test') and /test/ are equivalent.&lt;br /&gt;
&lt;br /&gt;
Mostly, Java does not have native support for regular expressions. While the String class has a few methods that can perform related functions, they do not necessarily follow the conventional rules of regular expressions. Proper regular expression support is available in Java through several packages, most notably java.util.regex, which is Sun's standard package available in Java 1.4+. This package provides two classes, Pattern and Matcher, which are respectively used to define and operate on regular expressions. These classes work in conjunction with the String class to perform regular expression functions. &lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11473</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11473"/>
		<updated>2008-05-29T12:49:37Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Regular Expressions in Ruby vs. Java ==&lt;br /&gt;
Ruby and Java both support Regular Expressions, but generally speaking, Ruby's dynamic typing and native regular expression support allow for equivalent or similar functions to be performed more simply and with less code. &lt;br /&gt;
&lt;br /&gt;
[[CSC/ECE 517 Summer 2008/wiki1 Assignment|Back to the assignment page]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11472</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11472"/>
		<updated>2008-05-29T12:45:35Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Regular Expressions in Ruby vs. Java ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Back to the assignment page: [[CSC/ECE 517 Summer 2008/wiki1 Assignment]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11438</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11438"/>
		<updated>2008-05-28T13:45:54Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;test text to see if I made the page right&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Back to the assignment page: [[CSC/ECE 517 Summer 2008/wiki1 Assignment]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_Assignment&amp;diff=11437</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 Assignment</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_Assignment&amp;diff=11437"/>
		<updated>2008-05-28T13:44:51Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Topics'''&lt;br /&gt;
&lt;br /&gt;
1. Regular-expression support&amp;lt;br&amp;gt;&lt;br /&gt;
   [[CSC/ECE_517_Summer_2008/wiki1_1_rp]]&lt;br /&gt;
2. Iterators and generators&amp;lt;br&amp;gt; &lt;br /&gt;
3. Reflection&amp;lt;br&amp;gt;  &lt;br /&gt;
4. Threads&amp;lt;br&amp;gt; &lt;br /&gt;
5. Hooks&amp;lt;br&amp;gt; &lt;br /&gt;
6. Arrays and hashes&amp;lt;br&amp;gt; &lt;br /&gt;
7. Eval&amp;lt;br&amp;gt; &lt;br /&gt;
   [[CSC/ECE_517_Summer_2008/wiki1_7_ev]]&lt;br /&gt;
8. Prototype-based programming&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
[[CSC/ECE 517 Summer 2008]]&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11436</id>
		<title>CSC/ECE 517 Summer 2008/wiki1 1 rp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Summer_2008/wiki1_1_rp&amp;diff=11436"/>
		<updated>2008-05-28T13:42:58Z</updated>

		<summary type="html">&lt;p&gt;Rapodraza: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;test text to see if I made the page right&lt;/div&gt;</summary>
		<author><name>Rapodraza</name></author>
	</entry>
</feed>