cancel
Showing results for 
Search instead for 
Did you mean: 

Using Regex in Blue Prism to replace newline, tabs and multiple spaces with 1 space

Tak.Kwok
Level 4

I am new to using Regex and needed to replace tabs, newline and multiple spaces with 1 space. Appreciate if you can provide the express and how to do that in Blue Prism.

Thanks,

Tak

2 BEST ANSWERS

Helpful Answers

Hi @Tak.Kwok 

Please download this vbo Blue Prism Digital Exchange

I will try with this data item

Mohamad_747_0-1724166478340.png

 

As you can see we have some spaces, tab, and newline

1. Use  action Get Regex Matches from VBO Regular Info Extractor and provide this inputs : 

Mohamad_747_1-1724166586630.png

For the regex string use this one "[\t\n\r ]+"

Now generate this outputs 

Mohamad_747_2-1724166662933.png

 

 

2. Use now action Replace RegEx Matches from VBO regular info extractor and provide this inputs : 

Mohamad_747_3-1724166765114.png

 

PS : please note that the [Matched Collection] is the output of the first action

For output generate this : 

Mohamad_747_4-1724166835371.png

Now run. Your flow should look like this : 

Mohamad_747_5-1724166942936.png

Tell me if its ok 🙂

 

 

 

 

View answer in original post

MichealCharron
Level 8

@Tak.Kwok 

You can use the one action Regex Replace in BP's Utility - Strings VBO.

With this Data Item:

MichealCharron_0-1724181651597.png

(Multiple tabs between rain and in. Multiple spaces between spain and falls. Multiple new lines between falls and mainly.)

Using the following text for the Pattern parameter:

\t+|\s{2,}|\n

And a space for the Replacement Data parameter:

MichealCharron_1-1724181925143.png

Will give you a output parameter data item of:

MichealCharron_2-1724182061076.png

 

Micheal Charron
RBC
Toronto, Ontario
Canada

View answer in original post

4 REPLIES 4

Hi @Tak.Kwok 

Please download this vbo Blue Prism Digital Exchange

I will try with this data item

Mohamad_747_0-1724166478340.png

 

As you can see we have some spaces, tab, and newline

1. Use  action Get Regex Matches from VBO Regular Info Extractor and provide this inputs : 

Mohamad_747_1-1724166586630.png

For the regex string use this one "[\t\n\r ]+"

Now generate this outputs 

Mohamad_747_2-1724166662933.png

 

 

2. Use now action Replace RegEx Matches from VBO regular info extractor and provide this inputs : 

Mohamad_747_3-1724166765114.png

 

PS : please note that the [Matched Collection] is the output of the first action

For output generate this : 

Mohamad_747_4-1724166835371.png

Now run. Your flow should look like this : 

Mohamad_747_5-1724166942936.png

Tell me if its ok 🙂

 

 

 

 

MichealCharron
Level 8

@Tak.Kwok 

You can use the one action Regex Replace in BP's Utility - Strings VBO.

With this Data Item:

MichealCharron_0-1724181651597.png

(Multiple tabs between rain and in. Multiple spaces between spain and falls. Multiple new lines between falls and mainly.)

Using the following text for the Pattern parameter:

\t+|\s{2,}|\n

And a space for the Replacement Data parameter:

MichealCharron_1-1724181925143.png

Will give you a output parameter data item of:

MichealCharron_2-1724182061076.png

 

Micheal Charron
RBC
Toronto, Ontario
Canada

Michael_S
Community Team
Community Team

Just to drop in and say - excellent answers @MichealCharron and @Mohamad_747! Thank you for including screenshots and strings, that's incredibly helpful of you. I'm marking both as Helpful Answers. 

@Tak.Kwok - please let us know if you now have the help you need!

Thanks. This solution works