1. comma in regex
- Posted by jessedavis Oct 31, 2010
- 937 views
haystack: ,"2010-01-04 00:00:06.0","2442733BDLYJNNJNB needle: year at beginning of string pattern: r:regex pat1 = r:new(",\\"([0-9]+) .+") commas are NOT special characters according to the manual error message: <0132>:: Syntax error - expected to see possibly ',', not '(' r:regex pat1 = r:new(",\\"([0-9]) .+") I have tried some variations, unsuccessfully. Whenever a comma appears in the pattern there is a problem. Any thoughts? Thanks, jd
2. Re: comma in regex
- Posted by jessedavis Oct 31, 2010
- 937 views
I always forget! EU4.0B4 on Ubuntu Linux
3. Re: comma in regex
- Posted by mattlewis (admin) Oct 31, 2010
- 914 views
jessedavis said...
haystack: ,"2010-01-04 00:00:06.0","2442733BDLYJNNJNB needle: year at beginning of string pattern: r:regex pat1 = r:new(",\\"([0-9]+) .+") commas are NOT special characters according to the manual error message: <0132>:: Syntax error - expected to see possibly ',', not '(' r:regex pat1 = r:new(",\\"([0-9]) .+")
I have tried some variations, unsuccessfully. Whenever a comma appears in the pattern there is a problem.
The problem here isn't actually the comma. After the \\ you close the quote, and euphoria was looking for a comma as part of parsing a function call. Because of the escaping used with regexes, it's useful to use back ticks `` to write the string. Try:
r:regex pat1 = r:new(`,"([0-9]+) .+`)
The back ticks ignore "normal" escaping rules, and make it easier, since you don't have to escape your regex escapes.
Matt