You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Bill Graham (JIRA)" <ji...@apache.org> on 2012/09/04 20:03:07 UTC
[jira] [Created] (PIG-2905) Improve documentation around REPLACE
Bill Graham created PIG-2905:
--------------------------------
Summary: Improve documentation around REPLACE
Key: PIG-2905
URL: https://issues.apache.org/jira/browse/PIG-2905
Project: Pig
Issue Type: Sub-task
Reporter: Bill Graham
Document how REPLACE uses a Java regex and link out to JDK docs describing reserved characters and escaping. From recent confusion on the users list:
{noformat}
> String source = "[02/Aug/2012:05:01:17";
> > String target ="[";
> > String replaceWith = "";
> > return source.replaceAll(source, target, replaceWith);
> Note that Java String.replaceAll() takes a regular expression for the 2nd
> parameter (i.e. target), and "[" is a special character. To use it as is,
> you have to escape it, so in your Pig script, you should do:
> REPLACE(date,'\\[','')
{noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (PIG-2905) Improve documentation around REPLACE
Posted by "Cheolsoo Park (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-2905?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13447883#comment-13447883 ]
Cheolsoo Park commented on PIG-2905:
------------------------------------
I will do this.
> Improve documentation around REPLACE
> ------------------------------------
>
> Key: PIG-2905
> URL: https://issues.apache.org/jira/browse/PIG-2905
> Project: Pig
> Issue Type: Sub-task
> Reporter: Bill Graham
> Assignee: Cheolsoo Park
>
> Document how REPLACE uses a Java regex and link out to JDK docs describing reserved characters and escaping. From recent confusion on the users list:
> {noformat}
> > String source = "[02/Aug/2012:05:01:17";
> > > String target ="[";
> > > String replaceWith = "";
> > > return source.replaceAll(source, target, replaceWith);
> > Note that Java String.replaceAll() takes a regular expression for the 2nd
> > parameter (i.e. target), and "[" is a special character. To use it as is,
> > you have to escape it, so in your Pig script, you should do:
> > REPLACE(date,'\\[','')
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Assigned] (PIG-2905) Improve documentation around REPLACE
Posted by "Cheolsoo Park (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-2905?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Cheolsoo Park reassigned PIG-2905:
----------------------------------
Assignee: Cheolsoo Park
> Improve documentation around REPLACE
> ------------------------------------
>
> Key: PIG-2905
> URL: https://issues.apache.org/jira/browse/PIG-2905
> Project: Pig
> Issue Type: Sub-task
> Reporter: Bill Graham
> Assignee: Cheolsoo Park
>
> Document how REPLACE uses a Java regex and link out to JDK docs describing reserved characters and escaping. From recent confusion on the users list:
> {noformat}
> > String source = "[02/Aug/2012:05:01:17";
> > > String target ="[";
> > > String replaceWith = "";
> > > return source.replaceAll(source, target, replaceWith);
> > Note that Java String.replaceAll() takes a regular expression for the 2nd
> > parameter (i.e. target), and "[" is a special character. To use it as is,
> > you have to escape it, so in your Pig script, you should do:
> > REPLACE(date,'\\[','')
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (PIG-2905) Improve documentation around REPLACE
Posted by "Bill Graham (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-2905?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bill Graham updated PIG-2905:
-----------------------------
Resolution: Fixed
Status: Resolved (was: Patch Available)
Committed, thanks Cheolsoo!
> Improve documentation around REPLACE
> ------------------------------------
>
> Key: PIG-2905
> URL: https://issues.apache.org/jira/browse/PIG-2905
> Project: Pig
> Issue Type: Sub-task
> Components: documentation
> Reporter: Bill Graham
> Assignee: Cheolsoo Park
> Attachments: PIG-2905.patch
>
>
> Document how REPLACE uses a Java regex and link out to JDK docs describing reserved characters and escaping. From recent confusion on the users list:
> {noformat}
> > String source = "[02/Aug/2012:05:01:17";
> > > String target ="[";
> > > String replaceWith = "";
> > > return source.replaceAll(source, target, replaceWith);
> > Note that Java String.replaceAll() takes a regular expression for the 2nd
> > parameter (i.e. target), and "[" is a special character. To use it as is,
> > you have to escape it, so in your Pig script, you should do:
> > REPLACE(date,'\\[','')
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (PIG-2905) Improve documentation around REPLACE
Posted by "Bill Graham (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-2905?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Bill Graham updated PIG-2905:
-----------------------------
Component/s: documentation
> Improve documentation around REPLACE
> ------------------------------------
>
> Key: PIG-2905
> URL: https://issues.apache.org/jira/browse/PIG-2905
> Project: Pig
> Issue Type: Sub-task
> Components: documentation
> Reporter: Bill Graham
> Assignee: Cheolsoo Park
>
> Document how REPLACE uses a Java regex and link out to JDK docs describing reserved characters and escaping. From recent confusion on the users list:
> {noformat}
> > String source = "[02/Aug/2012:05:01:17";
> > > String target ="[";
> > > String replaceWith = "";
> > > return source.replaceAll(source, target, replaceWith);
> > Note that Java String.replaceAll() takes a regular expression for the 2nd
> > parameter (i.e. target), and "[" is a special character. To use it as is,
> > you have to escape it, so in your Pig script, you should do:
> > REPLACE(date,'\\[','')
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (PIG-2905) Improve documentation around REPLACE
Posted by "Cheolsoo Park (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-2905?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Cheolsoo Park updated PIG-2905:
-------------------------------
Status: Patch Available (was: Open)
> Improve documentation around REPLACE
> ------------------------------------
>
> Key: PIG-2905
> URL: https://issues.apache.org/jira/browse/PIG-2905
> Project: Pig
> Issue Type: Sub-task
> Components: documentation
> Reporter: Bill Graham
> Assignee: Cheolsoo Park
> Attachments: PIG-2905.patch
>
>
> Document how REPLACE uses a Java regex and link out to JDK docs describing reserved characters and escaping. From recent confusion on the users list:
> {noformat}
> > String source = "[02/Aug/2012:05:01:17";
> > > String target ="[";
> > > String replaceWith = "";
> > > return source.replaceAll(source, target, replaceWith);
> > Note that Java String.replaceAll() takes a regular expression for the 2nd
> > parameter (i.e. target), and "[" is a special character. To use it as is,
> > you have to escape it, so in your Pig script, you should do:
> > REPLACE(date,'\\[','')
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (PIG-2905) Improve documentation around REPLACE
Posted by "Cheolsoo Park (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-2905?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Cheolsoo Park updated PIG-2905:
-------------------------------
Attachment: PIG-2905.patch
I added the following text to the REPLACE doc:
{quote}
Note that the REPLACE function is internally implemented using [java.string.replaceAll(String regex, String replacement)|http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replaceAll(java.lang.String, java.lang.String)] where 'regExp' and 'newChar' are passed as the 1st and 2nd argument respectively. If you want to replace [special characters|http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html#bs] such as '[' in the string literal, it is necessary to escape them in 'regExp' by prefixing them with double backslashes.
{quote}
Thanks!
> Improve documentation around REPLACE
> ------------------------------------
>
> Key: PIG-2905
> URL: https://issues.apache.org/jira/browse/PIG-2905
> Project: Pig
> Issue Type: Sub-task
> Components: documentation
> Reporter: Bill Graham
> Assignee: Cheolsoo Park
> Attachments: PIG-2905.patch
>
>
> Document how REPLACE uses a Java regex and link out to JDK docs describing reserved characters and escaping. From recent confusion on the users list:
> {noformat}
> > String source = "[02/Aug/2012:05:01:17";
> > > String target ="[";
> > > String replaceWith = "";
> > > return source.replaceAll(source, target, replaceWith);
> > Note that Java String.replaceAll() takes a regular expression for the 2nd
> > parameter (i.e. target), and "[" is a special character. To use it as is,
> > you have to escape it, so in your Pig script, you should do:
> > REPLACE(date,'\\[','')
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira