Skip to content

Commit

Permalink
fix: regex writing for . and / characters
Browse files Browse the repository at this point in the history
  • Loading branch information
fityannugroho committed Nov 9, 2023
1 parent 2358d4c commit 1f5624e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ validateCsvFile(path.join(__dirname, '../data/districts.csv'), {
tag: 'districts',
header: ['code', 'regency_code', 'name'],
/* The regex is already tested in https://regex101.com/r/cBkfxx/4 */
rowRegex: /^(\d{2}\.\d{2}\.\d{2}),(\d{2}\.\d{2}),(?!\s)((?!')[a-zA-Z0-9\-'.\\/() ]+)$/,
rowRegex: /^(\d{2}\.\d{2}\.\d{2}),(\d{2}\.\d{2}),(?!\s)((?!')[a-zA-Z0-9\-'./() ]+)$/,
});

validateCsvFile(path.join(__dirname, '../data/villages.csv'), {
tag: 'villages',
header: ['code', 'district_code', 'name'],
/* The regex is already tested in https://regex101.com/r/7FKCem/5 */
rowRegex: /^(\d{2}\.\d{2}\.\d{2}\.\d{4}),(\d{2}\.\d{2}\.\d{2}),(?!\s)((?!'|")[a-zA-Z0-9\-'"’.*\\/() ]+)$/,
rowRegex: /^(\d{2}\.\d{2}\.\d{2}\.\d{4}),(\d{2}\.\d{2}\.\d{2}),(?!\s)((?!'|")[a-zA-Z0-9\-'"’.*/() ]+)$/,
});

validateCsvFile(path.join(__dirname, '../data/islands.csv'), {
Expand All @@ -84,6 +84,6 @@ validateCsvFile(path.join(__dirname, '../data/islands.csv'), {
'is_outermost_small',
'name',
],
/* The regex is already tested in https://regex101.com/r/NoRXu9/7 */
rowRegex: /^(\d{2}\.\d{2}\.4\d{4}),(\d{2}\.\d{2}|),((?:[0-8][0-9]|90)°(?:[0-5][0-9]|60)'(?:[0-5][0-9].[0-9]{2}|60.00)"\s[N|S]\s(?:0\d{2}|1(?:[0-7][0-9]|80))°(?:[0-5][0-9]|60)'(?:[0-5][0-9].[0-9]{2}|60.00)"\s[W|E]),(0|1),(0|1),(?!\s)((?!')[a-zA-Z0-9\-'/ ]+)$/,
/* The regex is already tested in https://regex101.com/r/NoRXu9/8 */
rowRegex: /^(\d{2}\.\d{2}\.4\d{4}),(\d{2}\.\d{2}|),((?:[0-8][0-9]|90)°(?:[0-5][0-9]|60)'(?:[0-5][0-9]\.[0-9]{2}|60\.00)"\s[N|S]\s(?:0\d{2}|1(?:[0-7][0-9]|80))°(?:[0-5][0-9]|60)'(?:[0-5][0-9]\.[0-9]{2}|60\.00)"\s[W|E]),(0|1),(0|1),(?!\s)((?!')[a-zA-Z0-9\-'/ ]+)$/,
});

0 comments on commit 1f5624e

Please sign in to comment.