Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-03-22 10:21 AM
I Have a string that contains alphabets and numbers and Special characters .How can i get only numbers from string using blueprism?
------------------------------
Hari bp
------------------------------
------------------------------
Hari bp
------------------------------
Answered! Go to Answer.
1 BEST ANSWER
Helpful Answers
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-03-22 01:56 PM
Hi Hari,
You can extract numbers from a string by using Right, Left, IsNumber Functions natively, without using code stage or Regex.
And
------------------------------
naveen k
------------------------------
You can extract numbers from a string by using Right, Left, IsNumber Functions natively, without using code stage or Regex.
And
------------------------------
naveen k
------------------------------
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-03-22 10:46 AM
Hi @Haribp
In this case you can use the typical conversion functions. (ToNumber())
You will need to use some code to achieve this.
With this code, you will get from the string "ab2c3d1" this 231 as a Number
In this case, "text" is your input value. Your string with alphanumerics and numbers.
And "integer" is your output value. I cast this as a number at the end.
Hope this helps you. And if this solves the problem, remember mark as the best answer 🙂
See you in the community, bye 🙂
------------------------------
Pablo Sarabia
Architect
Altamira Assets Management
Madrid
------------------------------
In this case you can use the typical conversion functions. (ToNumber())
You will need to use some code to achieve this.
With this code, you will get from the string "ab2c3d1" this 231 as a Number
string content = string.Empty;
for (int i=0; i< text.Length; i++)
{
if (Char.IsDigit(text))
{
content += text;
}
}
if (b.Length>0)
{
integer = int.Parse(b);
}
else
{
integer = 0;
}
In this case, "text" is your input value. Your string with alphanumerics and numbers.
And "integer" is your output value. I cast this as a number at the end.
Hope this helps you. And if this solves the problem, remember mark as the best answer 🙂
See you in the community, bye 🙂
------------------------------
Pablo Sarabia
Architect
Altamira Assets Management
Madrid
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-03-22 12:05 PM
As an alternative to the code stage, Regex could be considered. With a pattern in style with "\d+" or perhaps "[0-9]+" to extract only numerical values from a given text string.
------------------------------
Happy coding!
Paul
Sweden
------------------------------
------------------------------
Happy coding!
Paul
Sweden
------------------------------
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)
Paul, Sweden
(By all means, do not mark this as the best answer!)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
24-03-22 01:56 PM
Hi Hari,
You can extract numbers from a string by using Right, Left, IsNumber Functions natively, without using code stage or Regex.
And
------------------------------
naveen k
------------------------------
You can extract numbers from a string by using Right, Left, IsNumber Functions natively, without using code stage or Regex.
And
------------------------------
naveen k
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
25-03-22 05:55 PM
@Haribp
Adding to @PvD_SE's reply, rather than using the "Regex Extract" action in BP's Utility String VBO, you can use the "Regex Replace" action to replace all non numeric characters with blanks. It is one action that passes out the value to one text data item.
The Regex pattern "[^0-9]" uses a negative character group [^] to specify any character not between 0 and 9 (inclusive) in a Unicode codespace.
------------------------------
Micheal Charron
Senior Manager
RBC
America/Toronto
------------------------------
Adding to @PvD_SE's reply, rather than using the "Regex Extract" action in BP's Utility String VBO, you can use the "Regex Replace" action to replace all non numeric characters with blanks. It is one action that passes out the value to one text data item.
If you can't make it out from the image, the parameters are:
Pattern: "[^0-9]"
Input Data: "The123Rain456In789Spain!@#$."
Replacement Data: ""

Input Data: "The123Rain456In789Spain!@#$."
Replacement Data: ""
The Regex pattern "[^0-9]" uses a negative character group [^] to specify any character not between 0 and 9 (inclusive) in a Unicode codespace.
------------------------------
Micheal Charron
Senior Manager
RBC
America/Toronto
------------------------------
Micheal Charron
RBC
Toronto, Ontario
Canada
RBC
Toronto, Ontario
Canada
