Page 1 of 1
find and string types
Posted: Sun Aug 06, 2006 5:41 pm
by cormullion
I've forgotten why these two
find expressions should give different results:
Code: Select all
(set 't " ; this is a comment")
(find "(\s*)(;+?)(.*)" t 0)
(find {(\s*)(;+?)(.*)} t 0)
I ought to know...
Posted: Sun Aug 06, 2006 8:09 pm
by Lutz
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.
Code: Select all
> (find {(\s*)(;+?)(.*)} t 0) ; only single backslash needed
0
> (find "(\\s*)(;+?)(.*)" t 0) ; double backslash necessary
0
>
Lutz
Posted: Sun Aug 06, 2006 10:44 pm
by cormullion
Of course. I knew that.... Well, i should have remembered. Thanks Lutz!