I have to match a string to a list of values and find out which value is matched.
List of Values
USD
U S D
U/S/D
UNITED STATES DOLLARS
I used the below pattern.
(U|UNITED)(.)?(\s)?(S|STATES)(.)?(\s)?(D|DOLLARS)(.)?
I also used Regex.Matches
to determine the value of the matched string.
It works perfectly fine for the below string except if the testdata has UNITEDSTATESDOLLARS.
The regex.matches returns only UNITEDSTATESDO.
Missing few letters from DOLLARS.
How do I fix the regex to retrieve all the matching words UNITEDSTATESDOLLARS
Test data | Output value |
---|---|
testUSD | USD |
testU.S.D | U.S.D |
testU/S/D | U/S/D |
testUNITEDSTATESDOLLARS | UNITEDSTATESDO** |