Java is equivalent to Python’s string lstrip()?
                                        
                    •
                    Java                                    
                I want to remove leading spaces from the string, but not trailing spaces - so trim () won't work I use lstrip () in Python, but I'm not sure if there is an equivalent in Java
for instance
" foobar "
Should be
"foobar "
I also want to avoid regular expressions if possible
Is there a built-in function in Java, or do I have to create my own method to perform this operation? (and the shortest path I can reach)
Solution
You can do this in regular expressions:
"    foobar    ".replaceAll("^\\s+","");
                
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        