ANSHUL
(MANTRI)
1
Hi
I have a below string. I need to extract date, company name, address, country and postal code from below string:
“4 November 2020\r\n \r\n \r\nMYANT AAA INTERNATIONAL\r\n\r\n10 Aenue Boulevard unit 03-77\r\nPTB 1, P O Box 78\r\nCOUNTRY 800012\r\n\r\nDear”
ptrobot
2
Are the information always in the same order? If not, how do you tell what is what?
ptrobot
4
Then you could just use String.Split to get the information.
arrayInfo = infoString.Split(Environment.NewLine.ToCharArray, StringSplitOptions.RemoveEmptyEntries)
strDate = arrayInfo(0)
strCompanyName = arrayInfo(1)
strAddress = arrayInfo(2) + Environment.NewLine + arrayInfo(3)
arrayConPos = System.Text.RegularExpressions.Regex.Split(arrayInfo(4), "(?<=\w) (?=\d)")
strCountry = arrayConPos(0)
strPostalCode = arrayConPos(1)