Hi,
I have the below string where I need to get values that are after the colon using regex.
currentText= “(1) Beneficiary Name: Jack Jones
(1) Beneficiary Street Address Line 1: 200 elm street
(1) Beneficiary Street Address Line 2: apartment 3G
(1) Beneficiary Street Address Line 3:
(1) Beneficiary City: Boston
(1) Beneficiary State: MA”
I tried using the below regex,
System.Text.RegularExpressions.Regex.Match(currentText,“Beneficiary Street Address Line 3\s*:\s*(.+?)(?=\r\n|$)” ).Groups(1).Value.Trim()
The above regex works when there is a value for the field. It grabs the correct value. But when the value is Blank, It pulls in data from next line. In this case,
The above regex should return a Blank value. But it returned “(1) Beneficiary City: Boston” . So, I want to grab blank value when it is blank in the string and I don’t want to grab the next entire line.
Can someone help me to tweak the above regex.
Thanks in Advance