Question

RGEX Deleting or Replacing anything after underscore


Badge

I still struggle with RGEX which is what I suspect is needed to accomplish a find and replace. I assume that StringReplacer is the transformer I should use, but I struggle with the REGEX.

I have 2 columns of data with various underscores followed by some character or words. Typically, it is _V and if was just that then I figured out how to do that, but I also have as other examples: VTF_SH_NNN_V, MSA_Name_NNN, and others. So, basically, I jut want to find "_ and delete it and anything after it. Can someone help me with the RGEX code. Thanks.


2 replies

Badge

I think I figured it out: I used the RGEX Expression: \\_.+

I used the following resources to help me parse out my question in case anyone is stuck like I was not really having used REGEX before. https://regex101.com/#pcre

This video helped: https://www.youtube.com/watch?v=koyjj87QbXg

Userlevel 2
Badge +17

I think I figured it out: I used the RGEX Expression: \\_.+

I used the following resources to help me parse out my question in case anyone is stuck like I was not really having used REGEX before. https://regex101.com/#pcre

This video helped: https://www.youtube.com/watch?v=koyjj87QbXg

Hi @dshaw, congrats you got a regex solution. Since the underscore '_' doesn't require escaping in regular expressions, you can remove the first backslash from your regex. This regex should work for you as well: _.+

Reply