(find-all {.*~~} (read-file {test.txt}) )
Can someone give me an example of how to code the above with a symbol containing the Quote
~~
Steven
(find-all {[~]} {here ~ or here ~})
(find {~} {here ~ or here ~})
? ;-)
Thanks newdep
I am looking to put the ~~ into a symbol
so insteadof this
(find-all {.*~~} (read-file {test.txt}) )
Something like
(setq searchstring {~~})
(find-all {.*searchstring} (read-file {test.txt}) )
Steven
find-all returns a list.. do you need a list? else a find could help out too..
> (find-all {[~]{1,2}} {blabal ~~ hoho ~ yes yes ~~~ no no~~} )
("~~" "~" "~~" "~" "~~")
> (regex "[~]{2}$" {blabal ~~ hoho ~ yes yes ~~~ no no~~})
("~~" 34 2)
Yes,
I would like a list from the file of all line that have the "~~" in middle.
I would like to return a list of where I have the charachters leading up to the ~~ captured.
Example
The File
---------
Books~~Shelock,Christie
Games~~monopoly,sorry
a plain line
Friends~~David,Bob
The list
("Books" "Games" "Friends")
Quote from: "SHX"
(find-all {.*~~} (read-file {test.txt}) )
Can someone give me an example of how to code the above with a symbol containing the ~~
Like this:
> (setq searchstring {~~})
"~~"
> (find-all (append {.*} searchstring) {hello ~ world ~~ hi there} )
("hello ~ world ~~")
Cheers, --Rick
> (find-all (append {(.*)} searchstring) {Books~~Shelock,Christie} $1)
("Books")
newdep thanks for your help.
rickyboy thanks it gives me exactly what I am looking for.
How does the 2 changes you made, work to give me what I was looking for?
(find-all (append {(.*)} searchstring) {Books~~Shelock,Christie} $1)
Quote from: "SHX"
How does the 2 changes you made, work to give me what I was looking for?
(find-all (append {(.*)} searchstring) {Books~~Shelock,Christie} $1)
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.
Hope that helps and doesn't confuse. Cheers, --Rick
Now I understand.
Thanks rickyboy.
Steven