cancel
Showing results for 
Search instead for 
Did you mean: 

Split Number and Text for Multiple Lines

Lily.L
Level 5

Hi there,

I want to split numbers and text and store them in different columns; reference number and reference text.

1/ I have a reference text box which has multiple lines; for example

In "Pet Category" Reference, we have:

[8899] cat - cat food

[9988] dog - dog food

[7788] pet - pet food

[9977] cow - cow milk

My BP code for splitting numbers and text is shown below. However, it only works for [8899] cat - cat food, but not others [the other references are not split - still in original form) Note: Since the code, Mid([Reference Output],3,6) is for extracting numbers and Replace([Reference Output],Left([Reference Output],9),"") is for extracting text. The result will be [8899] and cat - cat food [which are separate for reference number and reference text columns].

20026.png

20027.png

2/ My reference text box outcome will come in different ways; some of them will have 1 line, some of them will have 2 lines some of them will have 3 lines, and so on.

In this case, what's the best way I should do to split text and number; according to their reference text box?

Thank you so much!

M



------------------------------
Mia Mikela
------------------------------
6 REPLIES 6

John__Carter
Staff
Staff

Maybe the first step is to split the text into a collection of lines (Utility - Strings). Then loop through the collection and split the line into number & text.



------------------------------
John Carter
Blue Prism
------------------------------

MichealCharron
Level 8

@Mia Mikela,

You can use the action "Extract Regex All Matches" from Blue Prism's Utility - Strings VBO (Blue Prism Digital Exchange - Utility Strings) to extract that information into a collection.

19991.png
You can use the Regex pattern:
(?<ReferenceNumber>\[\d{4}\])\s+(?<ReferenceText>[^\r\n]+)
19992.png
19993.png

What you will end up with is a collection of data that of all matches no matter how many lines your original text has:

19994.png


------------------------------
Micheal Charron
Senior Manager
RBC
America/Toronto
------------------------------
Micheal Charron
RBC
Toronto, Ontario
Canada

Thanks @Micheal Charron,

May I ask, instead of splitting numbers and text , how about keeping the reference output in its original form - but in a separate line when added to the collection

What Regex pattern: I should use?

Note: Given the reference output looks like this:

[8899] cat - cat food
[9988] dog - dog food
[7788] pet - pet food
[9977] cow - cow milk

However, when I add them to the collection, they are looked like this: "[8899] cat - cat food [9988] dog - dog food [7788] pet - pet food [9977] cow - cow milk". So I want to split the line and keep its original form.

Thanks a lot!

M

 



------------------------------
Mia Mikela
------------------------------

Thanks @Micheal Charron,

May I ask, instead of splitting numbers and text , how about keeping the reference output in its original form - but in a separate line when added to the collection

What Regex pattern: I should use?

Note: Given the reference output looks like this:

[8899] cat - cat food
[9988] dog - dog food
[7788] pet - pet food
[9977] cow - cow milk

However, when I add them to the collection, they are looked like this: "[8899] cat - cat food [9988] dog - dog food [7788] pet - pet food [9977] cow - cow milk". So I want to split the line and keep its original form.

Thanks a lot!

M

@Mia Mikela

If you are just looking to split text by lines into a collection, as @John Carter pointed out, I would use the "Split Lines" action in Blue Prism's "Utility - Strings". Regex would be overkill in that situation.



------------------------------
Micheal Charron
Senior Manager
RBC
America/Toronto
------------------------------
Micheal Charron
RBC
Toronto, Ontario
Canada

Hi can you please have a look at my steps, I follow the steps, add loop, add split text. but it still doesn't work correctly

20012.png 20013.png

20014.png

20015.png

20016.png

20017.png

and result look like this:  [8899] cat - cat food[9988] dog - dog food



------------------------------
Mia Mikela
------------------------------