Re: regex observation & question regarding re:escape()
- Posted by _tom (admin) Sep 19, 2016
- 1420 views
jessedavis said...
In any event, the docs should agree with the performance!
regards, jd
My fault.
I can't find out how I got #/\*/ to work. It must have been some weird stuff I had on my computer.
I did have time to retry example 1
include std/console.e include std/regex.e as re sequence s0 = "Payroll is $***15.00" display( s0 ) --> Payroll is $***15.00 -- this is a valid Euphoria string -- this IS NOT a valid regex string -- when s0 is used with the regex language --> $ is a keyword --> * is a keyword --> . is a keyword -- you must escape these characters before using them in a regex -- then, you must escape the \ when writing a string sequence s1 = "Payroll is \\$\\*\\*\\*15\\.00" display( s1 ) --> Payroll is \$\*\*\*15\.00 -- the form required when writing a regex -- writing a string with a ` backtik is a bit shorter sequence s2 = `Payroll is \$\*\*\*15\.00` display( s2) --> Payroll is \$\*\*\*15\.00 -- the form required when writing a regex -- the Euphoria re:escape function adds the required backslashes -- to a sequence written with " delimiters sequence s3 = re:escape( s0 ) display( s3 ) --> Payroll is \$\*\*\*15\.00 -- the form required when writing a regex --Note: -- the strings re:escape(s0), s1, and s2 are only useful as literal patterns
thanks for pointing out my mistakes
_tom