1. comma in regex

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 

new topic     » topic index » view message » categorize

2. Re: comma in regex

I always forget! EU4.0B4 on Ubuntu Linux

new topic     » goto parent     » topic index » view message » categorize

3. Re: comma in regex

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu