How to get data from paragraph using regex

I have a paragraph like,

“Vicky is going to shop
And he bought apple for 1kg
The price $10
In price : (A to Z) he sell $12”

Here,
In price : (A to Z) he sell is constant
The amount will be dynamic.

I need to extract the amount $12

What is the Regex expression I need to use here

Hi @Vicky_K,

You can use this pattern.

(?<=In price \: \(A to Z\) he sell).*

Kind Regards.

@Vicky_K @omer.ozturk

I just did a minor update on Omer’s regex. I included the space character after the words “he sell”. So that it will just pick only $12 and not include the space before it.

Here’s the updated regex:
(?<=In price : (A to Z) he sell ).*

Kind regards,
Kenneth

Hi @Vicky_K

You can try with Regex Expression

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=In\sprice\s:\s\(A to Z\)\she\ssell\s)(\D.+)").Tostring

Regards
Gokul

Hello @Vicky_K
Try this regex pattern

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=\(A\sto\sZ\)\she\ssell\s)[\W\d]+").Tostring.Trim

hI @Vicky_K

Try this split alternative too

Split(txt,"In price : (A To Z) he sell")(1)

image

Split(txt," ")(Split(txt," ").Count-1)

image

Regards
Sudharsan

@Vicky_K try this regex
“(?<=In price : (A to Z) he sell)[$0-9\s]+”
Regards
Sreejith S S