Regular expression - remove extra text in a column

  • 1 September 2017
  • 7 replies
  • 6 views

Badge +8

Hi 

I have populated a column with an email body. Now I need a regex to remove all the text from the column that I do not need. I only need the 1st few sentences of the email body.

What Reg ex can I use? Is there one that saids remove all text after a certain word?

Thanks


7 replies

Userlevel 4
Badge +7

Hi

This should do what you want if there is a specific word you can use:

This will be stored in a collection variable and you can use the Get collection operation with an index of 0 to get the value you need. If you need more info see here:

Hope this helps

Userlevel 4
Badge +7

Hi

You will need to create an Integer variable with a default value of 0 and use this in the index section of the collection operation

Badge +8

The reg expression result is ;

I have line breaks and spaces in the column I am pulling from. I not sure if this makes a difference.

Userlevel 4
Badge +7

Hi

Can you post an example of the original text and what you want as the result?

Userlevel 4
Badge +7

Hi

Do you have an example?

Badge +8

Hi Paul

I managed to do a work around. I think the issue might be a line break.

Example:

data 1: 123  Data 2: 123 Data 3:123

Data 4:123

Dear who ever...

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

I want to remove the text from Dear onwards to leave only the data columns.

Userlevel 4
Badge +7

Hi Michelle Goodman

Try this:

[sS]*(?=Dear)

With the input text above, the result is

data 1: 123  Data 2: 123 Data 3:123

Data 4:123

 

;

You will have line breaks in it but you could do another regex set to replace, using the pattern and replacement text leave empty, which would remove the line breaks and you would have:

data 1: 123  Data 2: 123 Data 3:123Data 4:123 ;

Hope this helps

Reply