Details

    • Type: Sub-task Sub-task
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: documentation
    • Labels:
      None

      Description

      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:

      > 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,'\\[','')
      
      1. PIG-2905.patch
        2 kB
        Cheolsoo Park

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Patch Available Patch Available
        8h 28m 1 Cheolsoo Park 05/Sep/12 03:30
        Patch Available Patch Available Resolved Resolved
        2h 25m 1 Bill Graham 05/Sep/12 05:56
        Bill Graham made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Bill Graham added a comment -

        Committed, thanks Cheolsoo!

        Show
        Bill Graham added a comment - Committed, thanks Cheolsoo!
        Cheolsoo Park made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Cheolsoo Park made changes -
        Attachment PIG-2905.patch [ 12543792 ]
        Hide
        Cheolsoo Park added a comment -

        I added the following text to the REPLACE doc:

        Note that the REPLACE function is internally implemented using java.string.replaceAll(String regex, String replacement) where 'regExp' and 'newChar' are passed as the 1st and 2nd argument respectively. If you want to replace special characters such as '[' in the string literal, it is necessary to escape them in 'regExp' by prefixing them with double backslashes.

        Thanks!

        Show
        Cheolsoo Park added a comment - I added the following text to the REPLACE doc: Note that the REPLACE function is internally implemented using java.string.replaceAll(String regex, String replacement) where 'regExp' and 'newChar' are passed as the 1st and 2nd argument respectively. If you want to replace special characters such as '[' in the string literal, it is necessary to escape them in 'regExp' by prefixing them with double backslashes. Thanks!
        Bill Graham made changes -
        Component/s documentation [ 12312022 ]
        Hide
        Cheolsoo Park added a comment -

        I will do this.

        Show
        Cheolsoo Park added a comment - I will do this.
        Cheolsoo Park made changes -
        Field Original Value New Value
        Assignee Cheolsoo Park [ cheolsoo ]
        Bill Graham created issue -

          People

          • Assignee:
            Cheolsoo Park
            Reporter:
            Bill Graham
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development