From 9040ad657b411a5a396bc6ebfee72dfa7133545f Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Thu, 11 Jun 2009 14:31:37 -0700 Subject: [PATCH] adding string manipulation functions to org-babel.el --- lisp/org-babel.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lisp/org-babel.el b/lisp/org-babel.el index 5565388ca..bce0a4b8c 100644 --- a/lisp/org-babel.el +++ b/lisp/org-babel.el @@ -359,6 +359,9 @@ This is taken almost directly from `org-read-prop'." "Return t if STRING represents a number" (string-match "^[[:digit:]]*\\.?[[:digit:]]*$" string)) +(defun org-babel-reverse-string (string) + (apply 'string (reverse (string-to-list string)))) + (defun org-babel-chomp (string &optional regexp) "Remove any trailing space or carriage returns characters from STRING. Default regexp used is \"[ \f\t\n\r\v]\" but can be @@ -367,5 +370,10 @@ overwritten by specifying a regexp as a second argument." (setq string (substring string 0 -1))) string) +(defun org-babel-trim (string &optional regexp) + "Like `org-babel-chomp' only it runs on both the front and back of the string" + (org-babel-chomp (org-babel-reverse-string + (org-babel-chomp (org-babel-reverse-string string) regexp)) regexp)) + (provide 'org-babel) ;;; org-babel.el ends here