You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by bi...@apache.org on 2012/09/05 06:54:36 UTC

svn commit: r1380989 - in /pig/trunk: CHANGES.txt src/docs/src/documentation/content/xdocs/func.xml

Author: billgraham
Date: Wed Sep  5 04:54:35 2012
New Revision: 1380989

URL: http://svn.apache.org/viewvc?rev=1380989&view=rev
Log:
PIG-2905: Improve documentation around REPLACE (cheolsoo via billgraham)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/docs/src/documentation/content/xdocs/func.xml

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1380989&r1=1380988&r2=1380989&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Wed Sep  5 04:54:35 2012
@@ -24,6 +24,8 @@ INCOMPATIBLE CHANGES
 
 IMPROVEMENTS
 
+PIG-2905: Improve documentation around REPLACE (cheolsoo via billgraham)
+
 PIG-2882: Use Deque instead of Stack (mkhadikov via dvryaboy)
 
 PIG-2781: LOSort isEqual method (xalan via dvryaboy)

Modified: pig/trunk/src/docs/src/documentation/content/xdocs/func.xml
URL: http://svn.apache.org/viewvc/pig/trunk/src/docs/src/documentation/content/xdocs/func.xml?rev=1380989&r1=1380988&r2=1380989&view=diff
==============================================================================
--- pig/trunk/src/docs/src/documentation/content/xdocs/func.xml (original)
+++ pig/trunk/src/docs/src/documentation/content/xdocs/func.xml Wed Sep  5 04:54:35 2012
@@ -2896,7 +2896,7 @@ REGEX_EXTRACT_ALL('192.168.1.5:8020', '(
    <table>
        <tr>
             <td>
-               <p>REPLACE(string, 'oldChar', 'newChar');</p>
+               <p>REPLACE(string, 'regExp', 'newChar');</p>
             </td>
          </tr>  
    </table>
@@ -2915,10 +2915,10 @@ REGEX_EXTRACT_ALL('192.168.1.5:8020', '(
          </tr> 
                 <tr>
             <td>
-               <p>'oldChar'</p>
+               <p>'regExp'</p>
             </td>
             <td>
-               <p>The existing characters being replaced, in quotes. </p>
+               <p>The regular expression to which the string is to be matched, in quotes.</p>
             </td>
          </tr> 
                 <tr>
@@ -2941,6 +2941,16 @@ Use the REPLACE function to replace exis
 For example, to change "open source software" to "open source wiki" use this statement: 
 REPLACE(string,'software','wiki');
      </p>
+     <p>
+Note that the REPLACE function is internally implemented using
+<a href="http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String)">
+java.string.replaceAll(String regex, String replacement)</a>
+where 'regExp' and 'newChar' are passed as the 1st and 2nd argument respectively.
+If you want to replace 
+<a href="http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#bs">
+special characters</a> such as '[' in the string literal, it is necessary to escape them in 'regExp'
+by prefixing them with double backslashes (e.g. '\\[').
+    </p>
 </section>
 </section>