Can you help me to get Regular expression for below

Hi All,

I need to get the Regular Expressions to fetch the below values:

  1. Net Asset Value: $ 2,639,679
  2. Commitment: 3,000,000
  3. Less: Contributions: (2,302,493)
  4. Remaining Capital Commitment: $ 697,507

Please help on this

Here are the regular expressions to extract the values:

  1. Net Asset Value

regex

Net Asset Value:\s*\$?\s*([\d,]+)
  1. Commitment

regex

Commitment:\s*([\d,]+)
  1. Less: Contributions

regex

Less:\s*Contributions:\s*\(?([\d,]+)\)?
  1. Remaining Capital Commitment
Remaining Capital Commitment:\s*\$?\s*([\d,]+)

Each regex captures the numerical values while handling optional dollar signs and parentheses. Let me know if you need modifications! :blush:

Implementation in UiPath Assign Activity:

vb

NetAssetValue = System.Text.RegularExpressions.Regex.Match(inputString, "(?<=net asset value of \$)[\d,]+").Value
RemainingCommitment = System.Text.RegularExpressions.Regex.Match(inputString, "(?<=remaining capital commitment of \$)[\d,]+").Value
TotalCommitment = System.Text.RegularExpressions.Regex.Match(inputString, "(?<=total commitment of \$)[\d,]+").Value

These expressions will extract:

  • Net Asset Value: $2,639,679
  • Remaining Capital Commitment: $697,507
  • Total Commitment: $3,000,000

WHat about Commitment??
the values will be dynamic

Yes RegEx is always dynamic, until you handle properly your string values.

@naveen.s

actually if order is same then thise should do the job to match any numbr…and () generally means they are negative number can replace them once you read and consider value as negative

\(?\d{1,}[\d,]+\)?

cheers

1 Like

@Anil_G ,

I am using the below expression to get Net asset Value but not working:

System.Text.RegularExpressions.Regex.Match(ReadPage2, “((?\d{1,}[\d,]+)?”).Value

Check your String “ReadPage2” once and use it ReadPage2.trim.toString

(post deleted by author)

@naveen.s

duplicate

1 Like

Hi @naveen.s

What is your input data and required output data, could you please specify more to get us understandable.

@naveen.s

first of all check how the values look by writing the data to text file…then we can get the regex for each

cheers

Okay @naveen.s

You can use the below regular expressions,

  1. NetAsset Value $ 2,639,679
(?<=Net Asset Value \$\s+)[\d\,\.]+

2.Commitment 3,000,000

(?<=Commitment \$\s+)[\d\,\.]+

  1. Less: Contributions (2,302,493)
(?<=Less: Contributions\s*)[\(\)\d\,\.]+

  1. Remaining Capital Commitment $ 697,507
(?<=Remaining Capital Commitment \$\s*)[\d\,\.]+

Hope it helps!!

@naveen.s

please use this

(?<=Net Asset Value *\$ *)\(?\d{1,}[\d,]+\)?

cheers

Hi @naveen.s

1: Net Asset value: (?<=Net Asset Value\s)$\s*[\d,]+
2: Commitment: (?<=Commitment\s)[\d,]+
3: Less: Contributions: (?<=Less: Contributions\s)[-(\d,).]+
4: Remaining Capital Commitment: (?<=Remaining Capital Commitment\s)$\s*[\d,]+

Thanks!!

@naveen.s , please always sanitise the data before publishing online. I think you just published financial information of a member of a royal family. Either you or your employer could end up having to face the legal system.

(?:()?\s*$?\s*([\d,]+)\s*(?:))?

try this