dsubelman commented on PR #523:
URL: https://github.com/apache/maven-surefire/pull/523#issuecomment-1104101425

   > > If the test fails with escaping characters `	`, you can try using 
`String.replaceAll(String, String)` with regex.
   > > Instead of:
   > > ```
   > > return argLine
   > >     .replace( "\n", " " )
   > >     .replace( "\r", " " )
   > >     .replace( "\t", " " );
   > > ```
   > > 
   > > 
   > >     
   > >       
   > >     
   > > 
   > >       
   > >     
   > > 
   > >     
   > >   
   > > You can do:
   > > ```
   > > return argLine.replaceAll("\\s+", " ");
   > > ```
   > 
   > It does, but it also matches spaces (which it currently doesn't). On the 
other hand, it's one regex vs. three, so that could be a benefit. What do you 
think, @Tibor17?
   
   It also replaces multiple consecutive whitespaces with a single whitespace:
           
       List<String> whitespaces = List.of(
               "\n", 
               "\r",
               "\n\r",
               "\t", 
               " ",                    // single whitespace
               "  ",                   // double whitespaces
               "   ",                  // triple whitespace
               "        ",              // &#09;
               "\n\n\r\t        ",
               "  \n \n\r   \t           ");
           
       List<String> stripWhitespaces = whitespaces.stream()
               .map(str -> str.replaceAll("\\s+", "' '")).toList();
       
       System.out.println(stripWhitespaces);
   
   Output:
   
       [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to