I want to split BillingStreet into a custom Street__c and HouseNumber__c. According to what I have read so far online, I need to:
Instantiate a new Pattern object
//Pattern 'Test Street 123' OR '123 Test Street' OR 'Test 123 Street' Pattern MyPattern = Pattern.compile('[^\\d]*([\\d]+)[^\\d]*');
Instantiate a new Matcher object
Matcher MyMatcher = MyPattern.matcher(account.BillingStreet);
Process the result
if(MyMatcher.matches()){ account.Street__c = MyMatcher.group(???); account.HouseNumber__c = MyMatcher.group(1); }
The code for the House Number is working. But I need it to work for Street and also to enhance the Regex with the following examples: 'Further Test Street 123', '123 Further Test Street', 'Test Street 123a', '123a Test Street', 'Test 123a Street', 'Further Test Street 123a', '123a Further Test Street', 'Street 123', '123 Street', 'Street 123a', '123a Street' and all the same with 'Further-Test-Street 123' ...