Browse Source

adding string manipulation functions to org-babel.el

Eric Schulte 16 years ago
parent
commit
9040ad657b
1 changed files with 8 additions and 0 deletions
  1. 8 0
      lisp/org-babel.el

+ 8 - 0
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