Regular expression to read values, how to get right value?

Hi,

From this i need to get 1500 + 750

" \n\t\t\t\t\t1500kr-sevillkor"
" \n\t\t\t\t\t750kr,-sevillkor"

This is working for750, but with 1500 i gett “” what should i do?
System.Text.RegularExpressions.Regex.Match(SjälvriskVindruta, “\d+(?=kr,)”).ToString

1 Like

Hi
Welcome back to uipath community
This expression will get you the result
str_input = " \n\t\t\t\t\t1500kr-sevillkor"
" \n\t\t\t\t\t750kr,-sevillkor"

str_value1 = System.Text.RegularExpressions.Regex.Matches(str_input,”[\d]+”)(0).ToString. //output will be 1500

str_value2 = System.Text.RegularExpressions.Regex.Matches(str_input,”[\d]+”)(1).ToString. //output will be 750

Cheers @Doktorgud

Hi,

You cannot get value at former sentence, because there is not ", " but “-” after kr.

So, your pattern would be the following.

“\d+(?=kr[-,])”

Regards ,

@Yoichi Thanks its working!! :smiley:

1 Like

If i have this output " \n\t\t\t\t\t2325kr"

System.Text.RegularExpressions.Regex.Match(SjälvriskVindruta, “\d+(?=kr[-,])”).ToString

this will make it “” like my other problem, so what would be the correct solution?

Hi,

Can you try the following pattern?

"\d+(?=kr([-,]|$))"

Regards,

1 Like

You are amazing!! <3