Need help with extracting a particular substring or group of substring values from a given Input

Hi,

I have to extract a particular name from the “VirtualName” attribute on a UI Field.

The attribute name keeps changing, two of the examples are:

  1. 40364794 8 MOTON 270 270 D 3 D
  2. 40125394 9 INNER INVESTOR SERVICES T 276 276 D 1 D

In both the examples mentioned above, I need two outputs

  1. The number (270 in first example and 276 in second example)
  2. The complete Name (‘MOTON’ in first example and INNER INVESTOR SERVICES’ in second example)

How can I get these 2 substrings?
I need a common regular expression, because the names and numbers keep changing

  1. 40364794 8 MOTON 270 270 D 3 D
  2. 40125394 9 INNER INVESTOR SERVICES T 276 276 D 1 D

the parts in bold are they always a static length each time?

HI @Ruchita_Patil

Checkout this expressions

System.Text.RegularExpressions.Regex.Match(InputStr," [A-Z]{2,}").ToString.Trim

image

System.Text.RegularExpressions.Regex.Match(InputStr,"\d+(?=\s[A-Z]{1}\s\d\s)").ToString

image

Regards
Sudharsan

1 Like

Updated one @Ruchita_Patil

System.Text.RegularExpressions.Regex.Match(InputStr,"(?<=\d)[A-Z ]+(?=\d+\s\d+)").ToString.Trim

Regards
Sudharsan

Hi @Sudharsan_Ka

Thank you for this, but I do not want the last letter T

Hi @rmorgan

No, The numbers 8 and 9 might change, can be 11 and 12 as well