/usr/share/rep/lisp/rep/regexp.jl is in librep-dev 0.92.5-3build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #| rep.regexp bootstrap
$Id$
Copyright (C) 2000 John Harper <john@dcs.warwick.ac.uk>
This file is part of librep.
librep is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
librep is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with librep; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA
|#
(declare (in-module rep.regexp))
(open-structures '(rep.data))
(defun string-replace (regexp template string)
"Return the string created by replacing all matches of REGEXP in
STRING with the expansion of TEMPLATE.
If TEMPLATE is a string, it is expanded using the `expand-last-match'
function, otherwise TEMPLATE is called as a function with STRING as its
sole argument. It should return a string. Also it is guaranteed that
the last regular expression to have been matched was REGEXP when
TEMPLATE is called."
(let loop ((point 0)
(out '()))
(if (string-match regexp string point)
(loop (match-end)
(cons (if (stringp template)
(expand-last-match template)
(template string))
(cons (substring string point (match-start)) out)))
(if (null out)
string
(apply concat (nreverse (cons (substring string point) out)))))))
(defun string-split (regexp string)
"Return a list of substrings of STRING, each delimited by REGEXP."
(let loop ((point 0)
(parts '()))
(if (string-match regexp string point)
(loop (match-end)
(cons (substring string point (match-start)) parts))
(nreverse (cons (substring string point) parts)))))
(export-bindings '(string-replace string-split))
|