tyrauber / stock_quote

A ruby gem that retrieves stock quotes from IEX
MIT License
210 stars 57 forks source link

Constrain date-matching regex to match full lines #33

Closed drusepth closed 7 years ago

drusepth commented 7 years ago

Symbol YCAAO.BA has some dates in the format YPF SA FR BDS 21/10/2023 ARS1 that was matching the /\d{2}\/\d{2}\/\d{4}/ regex for date parsing, but fails because strptime errors against the defined template.

This PR adds start-of-line and end-of-line tokens to the string matching so that strptime only parses dates that match the defined formats and no more. For example, it will continue to match 02-25-1991, but will not match ABC 02-25-1991 or 02-25-1991 XYZ. If a date can't be parsed by strptime, parsing falls back on just returning the original string as per existing functionality.

Fixes #29. :+1: