I want to write a function that takes a string and cleans it form url un-friendly characters, using a regular expression or something else, how can this be achieved? Thanks
            Asked
            
        
        
            Active
            
        
            Viewed 557 times
        
    1
            
            
        - 
                    1What's an "unfriendly" character? You mean as a URL? – dmon Jun 26 '12 at 17:20
 - 
                    for example a space, #, ? .... thanks – user1010572 Jun 26 '12 at 17:25
 - 
                    1Perhaps you meant "encode"? http://stackoverflow.com/questions/3286067/url-encoding-in-android – dmon Jun 26 '12 at 17:26
 - 
                    1You can use URLEncoder.encode, or something like: private static String encodeForUrl(String input) { return input.toLowerCase().replaceAll("[^a-z\\s]", "").replaceAll("\\s", "-"); } to manually replace all non-URL-friendly characters – Cruceo Jun 26 '12 at 17:28
 - 
                    Android is an operating system. You are not writing a function in an operating system. You are writing a method in Java. – CommonsWare Jun 26 '12 at 18:25
 - 
                    Try this: http://stackoverflow.com/questions/3286067/url-encoding-in-android – Calvin Jan 24 '13 at 13:40