Skip to content

Conversation

@Petur06
Copy link

@Petur06 Petur06 commented Dec 4, 2020

Given statement with the following line
:61:2012031203CR20NMSCVS0015060871
the parser throws
System.Data.InvalidExpressionException: '2012031203CR20NMSCVS0015060871'

I narrowed it down to the fact that the amount in this case does not contain the decimal separator.

As seen in the regex, the decimal separator is expected. (?<ammount>\d*[,.]\d{0,2})

var regex = new Regex(@"^(?<valuedate>(?<year>\d{2})(?<month>\d{2})(?<day>\d{2}))(?<entrydate>(?<entrymonth>\d{2})(?<entryday>\d{2}))?(?<creditdebit>C|D|RC|RD)(?<fundscode>[A-z]{0,1}?)(?<ammount>\d*[,.]\d{0,2})(?<transactiontype>[\w\s]{4})(?<reference>[\s\w]{0,16})(?:(?<servicingreference>//[\s\w]{0,16}))*(?<supplementary>\r\n[\s\w]{0,34})*");

In the PR, you can see two changes to the regex:

  1. removed '?' from the 'fundscode' group
  2. added {0,1} to the 'ammount' group

Simply adding {0,1} to the 'ammount' group did not help, I also had to remove the '?' from the 'fundscode' group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant