Blueprism: how to use the replace function in a calculation stage?

天大地大妈咪最大 提交于 2019-12-14 03:56:01

问题


I am reading a text from an application using BluePrism. The text has the following structure (the number varies from case to case): "Please take note of your order reference: 525". I need to be able to extract the number from the text. Looking at the calculation stage, there is a replace function: replace(text, pattern, new-text). I want to use this function to replace all alphabetic characters in my text with an empty string to return only whatever is numeric. How can I input that in the pattern? So I want something like this:

Replace([Order confirmation text ], /^[A-z]+$/, " ")

Also, I tried to look for a proper documentation for the VBOs that are shipped with blueprism, but couldn't find any. Does anyone know where we can get documentations for blueprism functions?


回答1:


The Replace() function in calculate stage is the simplest possible one. It's not a regex one!

So, if the stirng is always in that format, then you can use:

Replace([Text],"Please take note of your order reference:","")

If the text is not always that standard, then you should rather use a regular expressions. To do that, you need to use an object, that will invoke a regex code.

In the standard blueprism objects, you can find:

Object: Utility - Strings C#
Action: Extract Regex Values

I think there is no Regex Replace action, by default, so if you'd like to, then you have to implement it. Below you can find a code that I am using:

Dim R as New Regex(Regex_Pattern, RegexOptions.SingleLine)
Dim M as Match = R.Match(Text)
replacement_result = R.Replace(Text,Regex_Pattern,replacement_string)




回答2:


Quick Answer if the pre text is constant use a Mid statement then this will take out the issue the other guy had with the right. i.e.

Mid("Please take note of your order reference: 525",42,6)

If you aim for a maximum number length it will stop at the end anyway.




回答3:


A few things here:

-Your pattern isn't matching because it's looking for a constant string of letters from start to finish (^ anchors to the beginning of the string and $ anchors to the end).

-You're replacing the pattern with a space, not an empty string, so you'll end up with a bunch of spaces in your result even if you correct the pattern.

-You said you only want to replace alphabetic characters, but it looks like you also want to get rid of spaces and colons.

Try replacing [A-Za-z :]+ with "".




回答4:


Your goal is to retrieve number from string then use Right():

Right("Please take note of your order reference: 525", 3)

This will return only numeric.

Regards Vimal



来源:https://stackoverflow.com/questions/47336549/blueprism-how-to-use-the-replace-function-in-a-calculation-stage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!