@@ -17,15 +17,16 @@ module.exports = {
17
17
18
18
extractor : ( keyValues , rawText ) => {
19
19
// first name
20
- let first_name = rawText . find ( ( line ) => line . match ( / ^ 1 ( .* ) $ / g) ) ;
21
- if ( first_name && first_name . substr ( 0 , 2 ) === '1 ' ) {
22
- first_name = first_name . replace ( '1 ' , '' ) ;
20
+ let first_name = rawText . find ( ( line ) => line . match ( / ^ 2 ( .* ) $ / g) ) ;
21
+ if ( first_name && first_name . substr ( 0 , 2 ) === '2 ' ) {
22
+ first_name = first_name . replace ( '2 ' , '' ) ;
23
23
}
24
+ first_name = first_name . split ( ' ' ) . shift ( ) ;
24
25
25
26
// last name
26
- let last_name = rawText . find ( ( line ) => line . match ( / ^ 2 ( .* ) $ / g) ) ;
27
- if ( last_name && last_name . substr ( 0 , 2 ) === '2 ' ) {
28
- last_name = last_name . replace ( '2 ' , '' ) ;
27
+ let last_name = rawText . find ( ( line ) => line . match ( / ^ 1 ( .* ) $ / g) ) ;
28
+ if ( last_name && last_name . substr ( 0 , 2 ) === '1 ' ) {
29
+ last_name = last_name . replace ( '1 ' , '' ) ;
29
30
}
30
31
31
32
// street address line 1 & 2
@@ -42,7 +43,7 @@ module.exports = {
42
43
}
43
44
44
45
// city, state, zip code
45
- const lineWithCityStateZipIndex = rawText . findIndex ( ( line ) => line . match ( / ^ ( [ A - Z a - z \s ] + , ) ? [ A - Z ] { 2 } \d + $ / g) ) ;
46
+ const lineWithCityStateZipIndex = rawText . findIndex ( ( line ) => line . match ( / ^ ( [ A - Z a - z \s ] + , ) ? [ A - Z ] { 2 } \d + \- ? \d + ? $ / g) ) ;
46
47
const lineWithCityStateZip = rawText [ lineWithCityStateZipIndex ] ;
47
48
48
49
if ( ! street_address_line_1 && lineWithCityStateZipIndex > 0 ) {
@@ -54,7 +55,7 @@ module.exports = {
54
55
street_address_line_2 = '' ;
55
56
}
56
57
57
- const matchedCityStateZip = / ^ ( [ A - Z a - z \s ] + , ) ? ( [ A - Z ] { 2 } ) ( \d + ) $ / g. exec ( lineWithCityStateZip ) || [ ] ;
58
+ const matchedCityStateZip = / ^ ( [ A - Z a - z \s ] + , ) ? ( [ A - Z ] { 2 } ) ( \d + \- ? \d + ? ) $ / g. exec ( lineWithCityStateZip ) || [ ] ;
58
59
let [ , city ] = matchedCityStateZip ;
59
60
const [ , , state , zip_code ] = matchedCityStateZip ;
60
61
if ( city ) {
0 commit comments