How do I get rid of the blanks on the list? Spaces have become list components, so how do I get rid of them all?
Result value
['[', ', '\n', '\r', '', '\n', '\r', '', '', '\n', '\r', '', ', '\n', '\r', '', '', '\n', '\r', ']
What should I do if I want to get rid of all the gaps in the list?
list remove whitespace del
You didn't write down your language, Typically, you can solve it using regular expressions.
//Java Example
List<String> list = new ArrayList<>();
list.add(" ");
list.add("\n");
list.add("\r");
list.add("\t");
System.out.println(list.size()); //Output: 4
list.removeIf(n->n.matches("\\s"); // Find blank characters such as tabs, line breaks, spaces, and so on.
System.out.println(list.size(); //output: 0
565 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
566 Who developed the "avformat-59.dll" that comes with FFmpeg?
592 GDB gets version error when attempting to debug with the Presense SDK (IDE)
868 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.