English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
عبرة فرعية/حرف خاص " (?:re) قسمة التعبير النمطي، دون تذكر النص المطابق.
import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class PatternExample { public static void main(String args[]) { //قراءة النص من المستخدم System.out.println("ادخل نصًا"); Scanner sc = new Scanner(System.in); String input = sc.next(); String regex = "(?:[0-9])"; //تجميع تعبير النمط Pattern pattern = Pattern.compile(regex); //استرجاع ملاحظة التطابق Matcher matcher = pattern.matcher(input); //تحقق من إجراء التطابق boolean bool = matcher.find(); if(bool) { System.out.print("إيجاد تطابق"); } else { System.out.print("إيجاد تطابق"); } } }
نتيجة الخروج
ادخل نصًا 9848022338 إيجاد تطابق