mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
advanced address parsing
This commit is contained in:
parent
ea08ab8a5e
commit
89a13f1475
5 changed files with 82 additions and 19 deletions
|
@ -1,6 +1,8 @@
|
|||
const ru = [' ','\\.',',',':','\\?','#','Я','я','Ю','ю','Ч','ч','Ш','ш','Щ','щ','Ж','ж','А','а','Б','б','В','в','Г','г','Д','д','Е','е','Ё','ё','З','з','И','и','Й','й','К','к','Л','л','М','м','Н','н', 'О','о','П','п','Р','р','С','с','Т','т','У','у','Ф','ф','Х','х','Ц','ц','Ы','ы','Ь','ь','Ъ','ъ','Э','э'];
|
||||
const en = ['_','','','','','','Ya','ya','Yu','yu','Ch','ch','Sh','sh','Sh','sh','Zh','zh','A','a','B','b','V','v','G','g','D','d','E','e','E','e','Z','z','I','i','J','j','K','k','L','l','M','m','N','n', 'O','o','P','p','R','r','S','s','T','t','U','u','F','f','H','h','C','c','Y','y','','','','','E', 'e'];
|
||||
|
||||
export const removeGarbage = (text: string): string => text.replace(/[^A-Za-z\-_0-9]/ig, '_').replace(/_{2,}/ig, '_');
|
||||
|
||||
export const toHours = (info: number): string => {
|
||||
const hrs = parseInt(String(info), 10);
|
||||
const min = Math.round((Number(info) - hrs) * 60);
|
||||
|
@ -9,5 +11,5 @@ export const toHours = (info: number): string => {
|
|||
};
|
||||
|
||||
export const toTranslit = (string: string): string => (
|
||||
ru.reduce((text, el, i) => (text.replace(new RegExp(ru[i], 'g'), en[i])), (String(string) || ''))
|
||||
removeGarbage(ru.reduce((text, el, i) => (text.replace(new RegExp(ru[i], 'g'), en[i])), (String(string) || '')))
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue