Question


Tcs
IN
Last activity: 26 Aug 2020 13:52 EDT
Need to help to extract a number from string
Hi All,
I need help with a expression to extract a number from a string.
String - EUR|0000149193|||||||||||||||||718492|LONG PHU 1
Need to extract - 718492
Can someone please help with how to extract the value through regular Pega expression.
Thanks
Rahul
***Updated by moderator: Lochan to update Categories***


ING Nederland N.V.
NL
If the position of your number is fixed, then use Substring function.
Example - @substring("EUR|0000149193|||||||||||||||||718492|LONG PHU",31,36) will return 718492
If the format of your string is fixed, the use whatcomesbeforelast and whatcomesafterlast function
Example - @whatComesAfterLast(@whatComesBeforeLast("EUR|0000149193|||||||||||||||||718492|LONG PHU", '|'), '|') will return 718492


Pegasystems Inc.
US
Adding to this, if your string has only this 6 digit number which you are trying to retrieve and no other 6 digit number is available then you can try to fetch the 6 digit regular expression.


Tcs
IN
Hi Mahesh,
There could be other numbers as well. I want the number to retrieved from in between the last 2 pipes.
Thanks & Regards,
Rahul


Pegasystems Inc.
US
@Rahul, you can try to search in the web regarding this query in the regular expression forums to fetch the string between last 2 pipes or try to go through the regular expression documentation for constructing the expression. I will also try to research on this and let you know if i can find one.


Tcs
IN
Thanks Prakash for the reply.
The position of the number is not fixed. There might be data in between previous pipes as well. The number to be retrieved will always come in between the last 2 pipes.
I will try the whatcomesbeforelast and whatcomesafterlast function and share the results.
Thanks again.


Pegasystems Inc.
US
maybe a simple java function like below would do?


DELL
IN
Hi,
prakash
If the position of the number is not fixed ,want to exact last three digits From a any number... ??


Pegasystems Inc.
IN
Accepted Solution


Tcs
IN
Thanks all for the replies. I was able to get the value using whatcomesbeforelast and whatcomesafterlast function.
Thanks again.