find-all query

Notices and updates
Locked
cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

find-all query

Post by cormullion »

With find-all, how do I specify an option without specifying an expression:

(find-all str-pattern str-text [expr] [int-option])

I want to find all the valid numbers in a string, so want to specify some options such as case-insensitive... But I don't want to process anything...

Sammo
Posts: 180
Joined: Sat Dec 06, 2003 6:11 pm
Location: Loveland, Colorado USA

Post by Sammo »

How about something like

> (find-all "(is)" "newLISPisNEWLISP" $1 1)
("IS" "is" "IS")

in which [expr] = $1.

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

Right. Although it seems like the $1 is just a filler, until you need the option...

Code: Select all

> (find-all "is" "newLISP is cool, is it")
("is" "is")
> (find-all "is" "newLISP is cool, is it" $1 0)
("is" "is")
> (find-all "is" "newLISP is cool, is it" $1 1)
("is" "is" "is")
[/code]

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

... or if there are no parenthesized sub-expressions:

Code: Select all

(find-all "is" "newLISPisNEWLISP" $0 1)
=> ("IS" "is" "IS")
$0 is always the entire expression found, without any processing.

Lutz

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

OK, thanks!

Locked