newLISP Fan Club

Forum => Anything else we might add? => Topic started by: cormullion on August 06, 2006, 10:41:15 AM

Title: find and string types
Post by: cormullion on August 06, 2006, 10:41:15 AM
I've forgotten why these two find expressions should give different results:



(set 't "       ; this is a comment")
(find "(s*)(;+?)(.*)" t 0)
(find {(s*)(;+?)(.*)} t 0)


I ought to know...
Title:
Post by: Lutz on August 06, 2006, 01:09:03 PM
In the first one, which is delimited by quotes you would have to escape the backslash with another backslash, which is not necessary in the second one, which is delimited by curly braces. Curly braces suppress pre processing and take the characters literally.



> (find {(s*)(;+?)(.*)} t 0) ; only single backslash needed
0
> (find "(\s*)(;+?)(.*)" t 0) ;  double backslash necessary
0
>

 

Lutz
Title:
Post by: cormullion on August 06, 2006, 03:44:12 PM
Of course. I knew that.... Well, i should have remembered. Thanks Lutz!