Hive regexp_extract data

后端 未结 3 1486
时光说笑
时光说笑 2021-01-26 08:38

I\'m trying to use regexp_extract on hive.

I have data which is varying in nature, such as:

a2=new something a1=asdasdsad;a2=old something;a3=asadasdsadsa

相关标签:
3条回答
  • 2021-01-26 09:24
    (?<=a2=)[^;]*(?:;|$)
    

    Try this.See demo.

    https://www.regex101.com/r/rC2mH4/7

    0 讨论(0)
  • 2021-01-26 09:26
    (?<=a2=)=?([^;\n]*)
    

    I think RegEx101 is pretty helpful for you to understand the logic. I tried the above expression and it seem to work to extract the content for a2 with or without ;.

    0 讨论(0)
  • 2021-01-26 09:39

    This simple regex will do the work:

    .*a2=?(.*?);
    

    It's your same regex but with only one capturing group (you don't need to capture what it's before the a2 key).

    0 讨论(0)
提交回复
热议问题