Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-4-20250514-thinking-32k· AnthropicHugging Face LMArena Human Preference 140K

I want to find multiple digits than by one character (.) and then more digits. What…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-sonnet-4-20250514’s answer.
  1. User

    I want to find multiple digits than by one character (.) and then more digits. What would be the Java Regex expression?

  2. Claude Assistant

    The Java regex expression you're looking for is:

    "\\d+\\.\\d+"
    

    Breaking it down:

    • \\d+ - matches one or more digits
    • \\. - matches a literal dot character (escaped because . is a special regex character)
    • \\d+ - matches one or more digits

    This pattern will match strings like:

    • 123.456
    • 1.2
    • 999.001

    If you want to use it in Java code:

    String pattern = "\\d+\\.\\d+";
    String text = "The price is 123.45 dollars";
    
    if (text.matches(".*" + pattern + ".*")) {
        System.out.println("Found decimal number");
    }
    
    // Or to find all matches:
    Pattern p = Pattern.compile(pattern);
    Matcher m = p.matcher(text);
    while (m.find()) {
        System.out.println("Found: " + m.group());
    }
    

    Note that in Java strings, you need to double-escape the backslashes, which is why \d becomes \\d and \. becomes \\..

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.