Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
151 views
in Technique[技术] by (71.8m points)

Extracting data from a text file using Regex

I have a document which I am trying to extract information from using a Regex extractor. I am trying to extract the value for Option 2 and Option 3 ie:

  • Option 2 will return €6644
  • Option 3 will return $8532

As both of them contain the same text I wish to withdraw, I would appreciate any help on how I can write my regex statement , which will allow me to extract the amount.

so far I have

((?<=Options2s-sWithdrawsasspecifiedsamountysfullyscashingsinspoliciesssIswishstoscashsin)[a-zA-Z0-9-s]{30})

Which doesn't bring anything back

Any help would be greatly appreciated

<b>Text : </b>

<p>
Option 2 - Withdraw a specified amount by fully cashing in policies

I wish to withdraw €6644 (insert amount and currency)

(Please note that we will cash in the appropriate number of policies to reach the closest possible figure below the amount you require.
The balance will then be taken across all the remaining policies.
Please specify your fund choices for this balance overleaf.)

Please note: If you've invested in a PruFund Protected Fund, cashing in policies will erode the Guaranteed Minimum Fund.

Notes

1 For information on withdrawal limits, please see your Key Features Document.

2

At least £500, ¤750 or US$750 must remain invested in each fund you hold.

3 If you have invested in one of the PruFund Range of Funds, withdrawals may be subject to a 28-day delay.
If you also hold other funds, this could mean your withdrawal is made in two payments.

Option 3 - Withdraw a specified amount from across all policies

I wish to withdraw

€8532

(insert amount and currency) from across all the policies in my bond.

Please specify your fund choices below.
</P>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try:

Option 2[sS]*?(€d+)[sS]*?Option 3[sS]*?(€d+)

See regex demo

  1. Option 2 - Matches 'Option 2'
  2. [sS]*? - Non-greedily matches 0 or more characters
  3. (€d+) - Matches '€' followed by one or more digits in Group 1
  4. [sS]*? - Non-greedily matches 0 or more characters
  5. Option 3 - Matches 'Option 3'
  6. [sS]*? - Non-greedily matches 0 or more characters
  7. (€d+) - Matches '€' followed by one or more digits in Group 2

The two numbers are returned in Groups 1 and 2.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...