Re: 4.0a3 - Two Regular Expression Libraries? -- We need your input!

new topic     » goto parent     » topic index » view thread      » older message » newer message
Tom said...

This could be an opportunity to create a Euphoria friendly regex library.

include std/regex.e as re 
regex r = re:new( "\\\\" ) 
object result = re:find( r, "Eup\\horia" ) 
? result 
 
   -- { 
   --    {4,4} 
   -- } 

This example shows how messy a regular expression can getsearching for just one character. The problem is that \ is an escape character in both the regex and the string you are searching. If you provide a regex-library that uses, say ~ , as an escape character then a regex should become much easier to read.

For those that like Perl, then a wrapped Perl library could be obtained from the archive.

Tom

Why not just code it as ...

include std/regex.e as re 
-- Look for a back-slash character 
regex r = re:new( #'\\' ) 
object result = re:find( r, #'Eup\horia' ) 
? result 
 
   -- { 
   --    {4,4} 
   -- } 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu