i want split string against following characters
~!@$%^&*()_+=<>,.?/:;"'{}|[]\, \n,\t, space
i tried use \\s regex delimiter don't want # included split character string this #funny should result this is #funny resulting values.
i have tried following doesn't work.
this #funny".split("\\s")
but doesn't work. ideas?
just specify characters want in square bracket, means any of. single escape java characters (like \") , double escape regex special characters (like \\[):
@test public void testname() throws exception { string[] split = "this #funny".split("[~!@$%^&*()_+=<>,.?/:;\"'{}|\\[\\]\\\\ \\n\\t]"); (string string : split) { logger.debug(string); } }
Comments
Post a Comment