Extract part of text

donatmeh

New Member
Hello there,
I am new on Blue Prism, and I was wondering how do I get a part of text (probably with Starts with and Ends with) from a data item.
Imagine we have a test like:
Be at miss or each good play home they. It leave taste mr in it fancy.
She son lose does fond bred gave lady get. Sir her company conduct expense bed any.
Sister depend change off piqued one. Contented continued any happiness instantly objection yet her allowance. Use correct day new brought tedious. By come this been in. Kept easy or sons my it done.

I would like to only extract: She son lose does fond bred gave lady get. Including spaces and everything.

How would I achieve something like this?

Thank you very much in advance
 

ruicosta

New Member
Hi @donatmeh , could you be more specific please?
If you already have the string you want why do you need to extract it?

I think you want to extract the first phrase of the second paragraph. Is it?

I'm also a newbie on BluePrism but I have some experience dealing with strings and I would like to help.
Can you be more specific about the logic that will guide the extraction?
 

donatmeh

New Member
Hi @ruicosta.
I actually have dynamic text. This is why I have to extract All in the middle of Masseverwalter and a newLine (in Java: "\n").

Imagine the current text is this reply of mine and it contains something like:
Masseverwalter: Ismet Peja Median
Mohrstraße 10
5020 Salzburg
Tel.: 0000/00 00 02, Fax: 0000/22 00 00-00
E-Mail: email@example.be

Basically what I want to extract what's there on the quotes!

Do you think I can achieve this?

Thank you
 

ruicosta

New Member
Ok. I don't have BluePrism with me right now and I still don't know all the text functions from it but maybe I can help you.
There are several different technics and one of them involves using the Utility -Strings VBO and this one I still don't know how to use.

But try with this one, that I think it will be the most simple, please take a look to the text functions that can be used in calculation stages.

  1. Find the position of the first quote inside the string;
  2. Extract the text beginning at that position+1 till the end of the text;
  3. In the text extracted find the position of the first quote;
  4. Now, go to the extracted text and make a new extraction, this time from the beginning of it till the position found -1
You will have to use more than one Calculation stage. I think there is a more simple - and I'm sure you can simplify this because I've already done it - but without having blueprism with me it's difficult to give an exact response.
 

VJR

Well-Known Member
Hi donatmeh,

Assuming you meant colon : as there are no quotes " in the above sample.
Below is what you need to use in a Calc stage


Mid([Input], InStr([Input], ":")+1, InStr([Input], [Newline Character])-InStr([Input], ":"))


Explanation:
The Mid function takes the parameters as below
1526634579023.png

So in our case these three parameters are the broken down version.

Mid
(
[Input]
, InStr([Input], ":")+1
,InStr([Input], [Newline Character])-InStr([Input], ":")
)

[Input] - is the Text that contains your Input string ....the one you posted above
InStr([Input], ":")+1 - Here we are using Instr to find the position of colon : within the Input string. +1 is used to read the text one character after : is found.
InStr([Input], [Newline Character]) - InStr([Input], ":" - Here we are finding the position of the newline character (explained below). Then subtracting that position with the position where the colon : is found which will return anything that is between the colon : and the newline.

In order to get the new line character there is an action in the 'Utility - Strings' called as 'Get Newline character'.
The resulting newline character will be stored in the a data item after you run this action.

The overall diagram looks as below

1526635058270.png


1526635089505.png


1526635138301.png

This is the resulting text after running the process.
If you need to remove the space before the "I" then you need to use Trim function or you can start from 2nd position InStr([Input], ":")+2 if you know that the text is going to always start from the 2nd position.


1526635174901.png
 

donatmeh

New Member
@ruicosta Thank you for your help. Will definitely consider it whenever I need such solution.
@VJR Thank you for your thorough explanation. As I have studied your solution, this really seems to be something that will not let you down in many cases. This as sure can be accepted as a solved solution, as I tried it (and you did) and it works like a charm!
Time was crucial so I dug deeper and constructed another solution to this problem.
as per my case; the form that is returned is always the same format. So I read the HTML dom elements and constructed a collection. On the element on which I was interested in, for instance, "Birthday: ", I extracted the row as a string and used regex to get the value I desired.
Your solution does not depend on regex, and that is the beauty of it! Will improve my work when the time is right.

Thank you very much for the help! Much appreciated.
 

Shweta

Active Member
How can we extract the date (06/03/2019) from below line in blueprism:

<a onmouseover="return overlib('active(Unsuspend Customer) since 06/03/2019', 'RIGHT', 'ABOVE');" onmouseout="return nd();" href="javascript:void(0);">active</a>
 
Last edited:

JaviDVP

New Member
Hi,


Another form as you can do it, is use a object with regex. You just need configure the "initialise" as you can see in the image 1
View attachment Capture 1.PNG

Imports this Namespaces.

create a new Page with a code block, like this



View attachment Capture 2.PNG
View attachment Capture 3.PNG


View attachment Capture 4.PNG
View attachment Capture 5.PNG



Inputs:
iText = the text where you search your substring
iRegex = the regex we need for do this search


Output:
result = the substring result


If result come empty, it means that the text we are looking for does not exist.

Example:

Inputs:
iText = Be at miss or each good play home they. It leave taste mr in it fancy.
She son lose does fond bred gave lady get. Sir her company conduct expense bed any.
Sister depend change off piqued one. Contented continued any happiness instantly objection yet her allowance. Use correct day new brought tedious. By come this been in. Kept easy or sons my it done.

iRegex = (s|S)he son lose does fond bred gave lady get\w\s+


Result = She son lose does fond bred gave lady get.
 
Top