Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
29
Task/String-matching/Emacs-Lisp/string-matching.l
Normal file
29
Task/String-matching/Emacs-Lisp/string-matching.l
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
(defun match (word str)
|
||||
(progn
|
||||
|
||||
(setq regex (format "^%s.*$" word) )
|
||||
|
||||
(if (string-match regex str)
|
||||
(insert (format "%s found in beginning of: %s\n" word str) )
|
||||
(insert (format "%s not found in beginning of: %s\n" word str) ))
|
||||
|
||||
(setq pos (string-match word str) )
|
||||
|
||||
(if pos
|
||||
(insert (format "%s found at position %d in: %s\n" word pos str) )
|
||||
(insert (format "%s not found in: %s\n" word str) ))
|
||||
|
||||
(setq regex (format "^.*%s$" word) )
|
||||
|
||||
(if (string-match regex str)
|
||||
(insert (format "%s found in end of: %s\n" word str) )
|
||||
(insert (format "%s not found in end of: %s\n" word str) ))))
|
||||
|
||||
(setq string "before center after")
|
||||
|
||||
(progn
|
||||
(match "center" string)
|
||||
(insert "\n")
|
||||
(match "before" string)
|
||||
(insert "\n")
|
||||
(match "after" string) )
|
||||
Loading…
Add table
Add a link
Reference in a new issue