bHaRaTh N
bHaRaTh N

Reputation: 11

Regex to get specific Character after occurrence of a specific string

I am trying to create a Regex to get a value after 'New Serial Number'

Input String : [EXT] EOL Resolved : 343250; Serial Number : OLD123 ; New Serial Number : NEW123; UPS Tracking Number : UPSTRN123;

I need output to be 'NEW123'

Tried :

Match(%K00291;"(?<=New Serial Number :)(.*;)";true)

But I am getting output as : NEW123; UPS Tracking Number : UPSTRN123;

Upvotes: 0

Views: 47

Answers (1)

Dmitrii Bychenko
Dmitrii Bychenko

Reputation: 186668

You should use .*? (*? - zero or more but as few as possible) instead of .* (which ends up to the last ;) in order to stop matching at the nearest ;:

 ..."(?<=New Serial Number :)(.*?)(?=;)"...

Finally, if you don't want to include trailing ; into match, let's put it as (?=;)

Upvotes: 1

Related Questions