DSSSL Library Reference: Part of the Modular DocBook Stylesheet distribution
Prev |  | Next

# length-string-number-part

## Name

length-string-number-part -- Returns the numeric part of a length string

## Synopsis

    (length-string-number-part lenstr)

## Description

Given a length as a string, return the numeric part.

## Example

`"100pt"` returns `"100"`. `"30"` returns `"30"`. `"in"` returns `""`.

## Author

Norman Walsh, <ndw@nwalsh.com>

## Source Code

    (define (length-string-number-part lenstr)
      ;; Returns the numeric part of a length string
      (let ((digits '(#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\.)))
        (let loop ((chars (string->list lenstr))
    	       (number-part ""))
          (if (or (null? chars) (not (member (car chars) digits)))
    	  number-part
    	  (loop (cdr chars) (string-append number-part
    					   (string (car chars))))))))

Prev | Home | Next
sgml-root-element? | Up | length-string-unit-part