regexstreamsets

I am using regex in stream selector in streamsets but it is not working as expected


I am trying to partition data on wether it matches a regex or not. The column contains the value 00000000081.48 and the expression is

str:matches(record:value('/OUT_HD_CURR_BAL'), '[0-9]+\.[0-9]+')

But it is behaving as if the output is false. Is anything wrong with the regex?


Solution

  • I believe it should be

    str:regExCapture(record:value('/OUT_HD_CURR_BAL'), '([0-9]+\.[0-9]+)', 1)
    

    If you need to get the boolean with str:matches, add .* around your expression:

    str:matches(record:value('/OUT_HD_CURR_BAL'), '.*[0-9]\.[0-9]+.*')
    

    str:matches needs to match the string from start till end and .* matches any text.