FAQ
Hi
I am trying to use REPLACE function in PIG to clean the string in following way..

REPLACE(REPLACE(REPLACE('string','.',' '),'-',' '),' ',' ')

So if string has got . or - or spaces , it removes it...

However when I do it using PIG it makes the string as null and does not give me result(because of special character?)


Any suggestions from brains out there?

Thanks
Sanjeev

Search Discussions

  • Jonathan Coveney at Feb 22, 2011 at 6:32 pm
    Following java regex, a . needs to be \\. The other two are fine.

    2011/2/22 Sanjeev Shrivastava <sanjeevs@yahoo-inc.com>
    Hi
    I am trying to use REPLACE function in PIG to clean the string in
    following way..

    REPLACE(REPLACE(REPLACE('string','.',' '),'-',' '),' ',' ')

    So if string has got . or - or spaces , it removes it...

    However when I do it using PIG it makes the string as null and does not
    give me result(because of special character?)


    Any suggestions from brains out there?

    Thanks
    Sanjeev
  • Jonathan Coveney at Feb 22, 2011 at 6:32 pm
    Basically what you were doing before was searching for ., which in regex is
    "anything," and then replace it with a '', or nothing.

    2011/2/22 Jonathan Coveney <jcoveney@gmail.com>
    Following java regex, a . needs to be \\. The other two are fine.

    2011/2/22 Sanjeev Shrivastava <sanjeevs@yahoo-inc.com>

    Hi
    I am trying to use REPLACE function in PIG to clean the string in
    following way..

    REPLACE(REPLACE(REPLACE('string','.',' '),'-',' '),' ',' ')

    So if string has got . or - or spaces , it removes it...

    However when I do it using PIG it makes the string as null and does not
    give me result(because of special character?)


    Any suggestions from brains out there?

    Thanks
    Sanjeev

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriespig, hadoop
postedFeb 22, '11 at 6:16p
activeFeb 22, '11 at 6:32p
posts3
users2
websitepig.apache.org

People

Translate

site design / logo © 2021 Grokbase