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