REGEX - How to obtain from a string the last occurence/match with a 10 digit number starting with 450

Hello all,

I need some help regarding to REGEX expressions, I went throw the forum but I didn’t find any related to numbers, only with words.

The goal is to obtain from a string the last occurence/match with a 10 digit number (only) in a string with this format: 450******* (the * are natural numbers between 0-9)

What I got so far: 450\d{7}(?!.*[1])

I really appreciate help from anyone, I couldn’t find a solution yet.

Thanks in advance :slight_smile:


  1. \450\d{7} ↩︎

Hi,

How about using RightToLeft option as the following?

System.Text.RegularExpressions.Regex.Match(yourString,"450\d{7}",System.Text.RegularExpressions.RegexOptions.RightToLeft).Value

Regards,

hi @jnunocosta
try this


variable.last.value

Hello Yoichi, I will try this solution, thank you for your feedback.

Hello Karan_Zaveri, thank you for your feedback, this solution works!

Hello again, another rare scenario occurred, imagine that we have the number 94450003394503332340, need to fetch the last number that has 450******* (in this case 4503332340, NOT 4500033945). Any solution to that?

Hi,

The following will work in both case.

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.