Code: Select all
(find-all {.*~~} (read-file {test.txt}) )
Steven~~
Code: Select all
(find-all {.*~~} (read-file {test.txt}) )
Steven~~
Code: Select all
(find-all {.*~~} (read-file {test.txt}) )
Code: Select all
(setq searchstring {~~})
(find-all {.*searchstring} (read-file {test.txt}) )
Like this:SHX wrote:Can someone give me an example of how to code the above with a symbol containing the ~~Code: Select all
(find-all {.*~~} (read-file {test.txt}) )
Code: Select all
> (setq searchstring {~~})
"~~"
> (find-all (append {.*} searchstring) {hello ~ world ~~ hi there} )
("hello ~ world ~~")
Code: Select all
> (find-all (append {(.*)} searchstring) {Books~~Shelock,Christie} $1)
("Books")
Saying {.*searchstring} is directing find-all (or regex) to look for a substring ending with the literal string "searchstring". But what you really wanted was for newLISP to evaluate the symbol searchstring, then prepend its value with the regex string ".*", which is what (append {.*} searchstring) does. After that, you really wanted the stuff before the ~~ -- putting the parens around the ".*" bit directs find-all to remember only the part that matches the ".*" bit. It then puts the string which matches it in the global $1 for you. All you need to do then, to have find-all return it for you, is to include the reference $1 as the third argument to find-all.SHX wrote:How does the 2 changes you made, work to give me what I was looking for?
(find-all (append {(.*)} searchstring) {Books~~Shelock,Christie} $1)