hello sorry but i’m new to this. How can I get just one word between ( ) in a string? I tried using .Split(“( )”.ToCharArray) and it didn’t work, I tried using .Split(CChar(“()”)) but also without success help me please
Hi @Marcelo_Bueno, You can use double Split:
Split((Split(text,"(")(1).ToString),")")(0).ToString
First you extract the data after the opening ( and then before the ending )
You can also use a regular expression:
output = System.Text.RegularExpressions.Regex.Match(inputString,"(?<=\()[\s\S]*?(?=\))").Value
output = String
inputString = String
thanks for your answer but i still have problems the text before the ( ) i can have separated but what is inside no. using what you gave me this problem has appeared now ↓
‘text’ is ambiguous, imported from ‘System.Drawing, System’ namespaces or types. uipata
Please send some sample text to extract data from.
Real Madrid (kiser)
But the text between the ( ) is not always the same, I want to have the two separated so that he can write it on another page.
Split((Split(your_string_variable,"(")(1).ToString),")")(0).ToString
Use the code from the previous post. Is good. Both of them
Hi Adrian,
First of all this is a very details explanation and thank you for doing this and sharing with us. This help me gain more knowledge in “String” manipulation while I starting my RPA journey (just started this year).
I had a problem that I had been working for few days and I am trying to acheive the split, remove breakline and space in a cell value in on a particular column from the data table.
Below are the details of my problem and thank you and those gurus in advance in helping me solving my problem.
Hi @Patrick_Kok
Try this:
output = System.Text.RegularExpressions.Regex.Replace(inputString,
"[^\p{L}|^\p{N}]"
,
"/"
)
This expression removes any non letter and non numeric character.
Then change separator in “Split String” activity from " / " to “/”
If you have any more questions, feel free to write
Hi Adrian,
Cools…is working and would you mind to explain a bit more on what is this parameter any where do I get more information on this parameters?
^\p{L} : I assume this is to remove non Letter
^\p{N} : I assume this is to remove non Numeric
^\p : Is for what purpose and is there more than just ^\p like ^\w or ?
Apologies for so many questions as a beginner in programming world and thanks you for taking your time to help and really apprecite it.
Hi Adrian,
I notice that the bot generate a lot of empty lines in between, do you know how can I get rid of these empty lines?
Patrick,
You can find all the necessary information at these links
https://www.regular-expressions.info/unicode.html#category
https://www.fileformat.info/info/unicode/category/index.htm
\w is equivalent to [a-zA-Z0-9_]
\p is category of …
^ is negation of … if used in [ ]
if the table in the previous image reflects your data, then you have a lot of white space. You can remove them using the Trim property.
output = System.Text.RegularExpressions.Regex.Replace(inputString.Trim,
"[^\p{L}|^\p{N}]"
,
"/"
)
Hi Adrian,
Thank you so much for the guidance and will take a look.
Hi Adrian,
Try your suggession but still having an issues but manage to get it work by using the if function .
Was thinking is there more elegant way of solving my problem and thank you for your time in answering my problem.
Okay Patrick, I get it now. You only need to extract the ID numbers.
The solution is as follows:
splitedString = System.Text.RegularExpressions.Regex.Replace(inputString.Trim, "[^\p{N}]" , " ")
Change separator in “Split String” activity from "/"
to " "
Then assign array to remove empty items:
splitedString = splitedString.Where(Function(x) Not String.IsNullOrWhiteSpace(x)).ToArray
Output data:
Hi Adrian,
Is working perfectly now and this is really cool and fun getting the robot to work…I learn something new each time I posted my problem and thank you so much for your time and guidance.
Great work, helps a lot. Thank you.
Hi Adrian,
Apologies to trouble you again, as I am trying to optimising the bots on some reducancy process and as of how could I remove those duplicate numbers in the array? I have try Union (from this link How to remove a duplicates values from the array and listbut couldn’t get the result.
Thanks you in advance for your help and guidance once again.
Hi @patrick-cm.kok
Have you checked this code from below?
Example data:
arr_numbers = {123456,123456,234567,345678,234567,456789,123456}
arr_strings = {"123456","123456","234567","345678","234567","456789","123456"}
Code:
arr_numbers = arr_numbers.Union(arr_numbers).ToArray
arr_strings = arr_strings.Union(arr_strings).ToArray
Result: