| Paste number 63847: | Nonregular Expressions |
| Pasted by: | bobbysmith007 |
| 4 months, 2 weeks ago | |
| None | |
| Paste contents: |
| (in-package :cl-ppcre) (defvar *open-parens* 0) (defvar *close-parens* 0) (defparameter *tree* `(:SEQUENCE "function" (:GREEDY-REPETITION 0 NIL :WHITESPACE-CHAR-CLASS) #\( (:GREEDY-REPETITION 0 NIL (:filter ,#'(lambda (pos) (let ((char (char *string* pos))) (cond ((char= char #\( ) (incf *open-parens*) (+ 1 pos)) ((char= char #\) ) (incf *close-parens*) (if (<= *close-parens* *open-parens*) (+ 1 pos) (progn (setf *open-parens* 0 *close-parens* 0) nil))) (T (+ 1 pos)))))) ) #\))) (cl-ppcre:scan-to-strings *tree* "some times I like to \"function (calling all coppers (), another param (), test)\" just to see what happens") > "function (calling all coppers (), another param (), test)" |
Annotations for this paste:
| Annotation number 1: | Getting CL-PPCRE to return a parse-tree |
| Pasted by: | bobbysmith007 |
| 4 months, 2 weeks ago | |
| Paste contents: |
| (cl-ppcre::parse-string #?/function\s*\(.*\)/ ) ;;above I have replaced the :everything node with a :filter node |