Removing whitespace in Java string?

Posted by waitinforatrain on Stack Overflow See other posts from Stack Overflow or by waitinforatrain
Published on 2010-03-01T01:36:07Z Indexed on 2010/06/17 23:23 UTC
Read the original article Hit count: 212

Filed under:
|
|

Hi guys, I'm writing a parser for some LISP files. I'm trying to get rid of leading whitespace in a string. The string contents are along the lines of:

         :FUNCTION (LAMBDA
                   (DELTA
                    PLASMA-IN-0)
                 (IF
                  (OR
                   (>=
                    #61=(+
                         (*
                          1
                          DELTA)
                         PLASMA-IN-0)
                    100)
                   (<=
                    #61#
                    0))
                  PLASMA-IN-0
                  #61#))

The tabs are all printed as 4 spaces in the file, so I want to get rid of these leading tabs.

I tried to do this: string.replaceAll("\\s{4}", " ") - but it had no effect at all on the string.

Does anyone know what I'm doing wrong? Is it because it is a multi-line string?

Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about regex