Use a raw string in Java in Replit

Question: How to use raw string in Java in Replit? I wanna write "\\s|\\.|\\?" in the similar manner as in Python: r"\s|\.|\?".

import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in).useDelimiter("\\s|\\.|\\?");
    scanner.close();
  }
}
1 Like

Hi @EmilySeville7cfg thanks for your question.

I think I understand the issue you are needing support with. I am assuming you have already looked at sites such as W3 Schools Java Regular Expressions to read more about the problem?

Can you help the community answer your question by providing some test data and expected output? For example if you wanted the user to type something in like Hello world I use Replit and output:

Hello
World
I
Use
Replit

Sample input data: ab...c??. dd. It’s expected to delimit these three words by <space>, . and ?.