;;; -------------------------------------------------------------------------------------
;;; Get a reference to the Regular Expression Object object
;;; -------------------------------------------------------------------------------------
;;; Result: a vla object for the regular expression tools
;;; -------------------------------------------------------------------------------------
) ;_ end of or
) ;_ end of progn
) ;_ end of if
*RX-Link*
) ;_ end of defun
;;; -------------------------------------------------------------------------------------
;;; Change settings for regexp
;;; -------------------------------------------------------------------------------------
;;; Arguments:
;;; multiline = nil -> Stop- / t -> Don't stop at line ends
;;; global = nil -> only find 1st occurence; t -> find all occurences
;;; ignorecase = nil -> case sensitive; t -> case insensitive
;;; -------------------------------------------------------------------------------------
;;; Result: undefined
;;; -------------------------------------------------------------------------------------
(defun RX:
Set (multiline global ignorecase
) 'Multiline
-1
0
) ;_ end of if
) ;_ end of vlax-put
'Global
-1
0
) ;_ end of if
) ;_ end of vlax-put
'IgnoreCase
-1
0
) ;_ end of if
) ;_ end of vlax-put
) ;_ end of progn
) ;_ end of if
) ;_ end of defun
;;; -------------------------------------------------------------------------------------
;;; Find positions matching the pattern in the string
;;; -------------------------------------------------------------------------------------
;;; Arguments:
;;; string = The string to search through
;;; pattern = The regular expression patter to search for
;;; -------------------------------------------------------------------------------------
;;; Result: A list containing dotted pairs of (Position . Value)
;;; -------------------------------------------------------------------------------------
;;; Example
;;; (RX:Search "\"Test,6\",34,45.6,\"48\"" "(\\s*\"[^\"]*\"\s*,)|(\\s*[^,]*\\s*,)")
;;; Will return a list containing the positions & values after parsing the CVS string.
;;; ((0 . "\"Test,6\",") (9 . "34,") (12 . "45.6,"))
;;; -------------------------------------------------------------------------------------
(defun RX:Search
(string pattern
/ lst col item
) (vlax-Put *RX
-Link
* 'Pattern pattern
) ;Set the pattern to match ;; Get the collection of match objects
;; Loop through collection & place into return list
;; Get the position & length
) ;_ end of while
) ;_ end of progn
) ;_ end of if
(reverse lst
) ;Return list in correct order ) ;_ end of progn
) ;_ end of if
) ;_ end of defun