gpt-4-0314· openai
Suzhen/CodeChat
写一段java代码, 要求用正则匹配字符串,如果字符串全是数字返回true,否则返回false
- User
写一段java代码, 要求用正则匹配字符串,如果字符串全是数字返回true,否则返回false
- Assistant
import java.util.regex.Pattern; public class NumberValidation { public static void main(String[] args) { String inputStr = "12345"; System.out.println(isAllDigits(inputStr)); } private static boolean isAllDigits(String inputStr) { Pattern pattern = Pattern.compile("^\\d+$"); return pattern.matcher(inputStr).matches(); } }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.