Split o Substring of get text

I have the next text "Oferta 353 Mecánico Hidráulico Automotriz - Con… \n (70 candidatos inscritos) and i need the number , in this example the number is 70, but the number can be one digit,two digits,three digits

1 Like

Lets assume we can rely on candidatos… and use it as an anchor:

grafik

Assign Activity
strValue = System.Text.RegularExpressions.Regex.Match(strText,strPattern).Value.Trim

When an int32 is needed

intValue = CInt(System.Text.RegularExpressions.Regex.Match(strText,strPattern).Value.Trim)

Is the number always after a ( character? Does it always have “candidatos inscritos” after it?

If so…

System.Text.RegularExpressions.RegEx.Match(yourVar,"(?<=\()(.*)(?= candidatos)")

Assume u have the input string saved in a variable named Strinput

There are two ways to get this

  1. With split method as u want

Use a assign activity like this

Stroutput = Split(Split(Strinput.ToString, “(“)(1).ToString, “ “)(0).ToString.Trim
  1. With Regex method
    Now Use a assign activity like this
Stroutput = System.Text.RegularExpressions.Regex.Match(Strinput.ToString, “(\d+)(?=\scandidatos)”).Value

Reference

Explanation

Hope this helps

Cheers @Julian_Torres_Torres

Hi @Julian_Torres_Torres

Input= "Oferta 353 Mecánico Hidráulico Automotriz - Con… \n (70 candidatos inscritos)"
Output= System.Text.RegularExpressions.Regex.Match(Input,"\d+(?=\scandidatos)").Value

Hope it helps!!

Hi @Julian_Torres_Torres

Try this

[0-9]+(?=\s+candidatos)

System.Text.RegularExpressions.Regex.Match(Input,"[0-9]+(?=\s+candidatos)").Value

Hope this helps!!

Hope it’s all clarified
Let us know for any clarification @Julian_Torres_Torres

Hi.

Con este texto, ¿cómo se puede trabajar con él?
“Recibidos(6)”

I need the number

Thanks

Let us scope 1 Topic = 1 Question. So thers can faster solution for their similar use cases

Simple pattern:
grafik

more specific
grafik

Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

Hi

Try This pattern
in assign activity
extractedVal = System.Text.RegularExpressions.Regex.Match(“InputValue”,“(\d+)(?=\scandidatos)”).ToString

Thank you

Hi
Try this pattren

StringVal = System.Text.RegularExpressions.Regex.Match(“Recibidos(6)”,“((?<=Recibidos()\d+)”).ToString

Thank you

I have the next error