Closed matthewmayer closed 1 year ago
IMO instead of doing this strange pattern duplication stuff we should rather change the implementation to not use replacewithnumber and instead use a simple regex replace with numeric without leading zero or something.
Note if you change the implementation it needs to handle a bunch of different localization patterns beyond simple numbers, i see the following unique patterns. Note the ones with slashes in, which have two numbers.
[
' #', ' ##', ' ###', ' ####',
' s/n.', '#', '# bis', '##',
'## bis', '###', '### I', '### II',
'### III', '### bis', '####', '#####',
'###/#', '###/2', '###a', '###b',
'###c', '##/#', '##a', '##b',
'##c', '#/#', "'א#", "'א##",
"'ב#", "'ב##", ', #', ', ##',
'Bloc ##'
]
Team Decision
arrayElement(patterns).replace(/#+/g, (m) => string.numeric(m.length)
# -> number
transformation
Clear and concise description of the problem
Building numbers that start with a zero lead to addresses like '013 Schultz Circles' which look incorrect.
Suggested solution
Change the patterns. As this uses replaceSymbolWithNumber we only have the choice of # (0-9) or ! (2-9) as special chars.
We can use a pattern like
['1##', '!##', '1###', '!###', '1####', '!####']
to ensure the numbers can start with any of 1-9, but not 0. This causes a slight side-effect that numbers starting with 1 will be more common. However Benford's law means thats not unrealistic anyway.Alternative
No response
Additional context
No response