java - Check if a String only contains digits and the digits are not the same using REGEX? -


  111111111 - अमान्य A121278237 - अमान्य 7777777777 - अमान्य 121263263 - मान्य 111111112 - वैध  

  ^ ([0- 9]) (?! \ 1 + $) [0-9] + $  

काम करना चाहिए

स्पष्टीकरण:

  1. एक अंक से मेल करें और इसे बैक्रेफरेंस में कैप्चर करें # 1: ( [0- 9])

  2. मान लें कि किसी भी लम्बाई (> 1) से मेल खाने वाली एक ही अंक का मिलान करना असंभव है, उसके बाद स्ट्रिंग का अंत: (?! \ 1 + $)

  3. फिर स्ट्रिंग के अंत तक अंकों के किसी भी स्ट्रिंग से मिलान करें: [0-9] + $

संपादित करें: बिल्कुल, जावा में आपको स्ट्रिंग के अंदर बैकस्लैश से बचने की आवश्यकता है ( "\\ ")।


Comments

  1. Thanks for the post, I am techno savvy. I believe you hit the nail right on the head. I am highly impressed with your blog.
    It is very nicely explained. Your article adds best knowledge to our Java Online Training from India.
    or learn thru Java Online Training from India Students.

    ReplyDelete

Post a Comment