Such as: 13933991133, only consists of the three Numbers 139
16866881166, only consists of the three Numbers 168
How do you write the regular ah, try for a long time without success
CodePudding user response:
If is to determine the three Numbers, are better to write, not sure the three Numbers, that how to get the
CodePudding user response:
[345678] "^ 1 \ \ d {1} $"
CodePudding user response:
refer to the second floor jx315425246 response: [345678] "^ 1 \ \ d {1} $" This seems to be no CodePudding user response:
If certain number, 138, for example, you can use "[138] {11}" the regular, match out 13833888833, but the three Numbers are 0-9 3 digital combination, any how, you do not have what idea the CodePudding user response:
reference 4 floor weixin_40963517 response: if certain number, 138, for example, you can use "[138] {11}" the regular, match out 13833888833, but the three Numbers are 0-9 3 digital combination, any how, you do not have what idea the Three before match, if all match [345678] "^ 1 \ \ d {9} $" first bit is 1, 2, 345678, the rest a number from 0 to 9 CodePudding user response:
Regular is used to speed up the development, if it's not a regular faster, don't have a regular { Var b1=DigitsOnly (" 13933991133 ", 3);//true Var b2=DigitsOnly (" 16866881166 ", 3);//true Var b3=DigitsOnly (" 12345678901 ", 3);//false } The static bool DigitsOnly (string s, int who) { Return s.A ll (x=& gt; Char. IsDigit (x)) & amp; & S.G roupBy (x=& gt; X). The Count ()==who; } CodePudding user response:
The frontal 1. The regular not do 2. If regular must go to do, that might, in turn, think, check whether there is any non,3,9 number 1 CodePudding user response:
(? (?=\ d) [139] | \ w) CodePudding user response:
From the beginning to the end is ^ (? (?=\ d) [168] | \ w) + $ CodePudding user response:
6th floor can in fact as long as you go to the count, more than three different Numbers is false String STR="13933991133"; Bool isPhoneNumber=Regex. IsMatch (STR, @ "^ \ d {11} $") & amp; & STR. Distinct (). The Count ()==3; CodePudding user response:
Clumsily, first must be 1, and then choose 2 C from 9 number 9 2=36 kinds of combinations CodePudding user response:
Several brothers hard upstairs, but did not achieve the result that I want,, His own ideas a noon, thought of a regular: 1 (\ d) (\ d) (1 | | \ \ 1 2) {8}, achieves the demand CodePudding user response:
13333991133 is not through CodePudding user response:
1 ([1, 2, 3] {10} | 4-trichlorobenzene [1] {10} |,2,5 [1] {10} |,2,6 [1] {10} |,2,7 [1] {10} |,2,8 [1] {10} |,2,9 [1] {10} | [1 4] {10} |,3,5 [1] {10} |,3,6 [1] {10} |,3,7 [1] {10} |,3,8 [1] {10} |,3,9 [1] {10} |].enlighened {10} | minus [1] {10} |,4,7 [1] {10} |,4,8 [1] {10} |,4,9 [1] {10} | 6 [1] {10} | [1, 5, 7] {10} |,5,8 [1] {10} | [1, 9] {10} | [1, 6] {10} |,6,8 [1] {10} |,6,9 [1] {10} | proposal [1] {10} |,7,9 [1] {10} |,8,9 [1] {10}) Take no thank CodePudding user response:
Your packet capture if the first three Numbers two and three are the same, began to different, behind your verification is not successful, such as the 13th floor, such as 13333991133, 13111112311111111311, this is wrong, you You have to start 1, I under this changeRegex. IsMatch (STR, @ " ^ 1 \ d {10} $" The 14 floor directly give you the full combination of CodePudding user response:
Don't know how to use regular, but you can use the set checks if a string contains a few non repetitive characters, CodePudding user response:
On the 14th floor assky124 reference response: 1 ([1, 2, 3] {10} | 4-trichlorobenzene [1] {10} |,2,5 [1] {10} |,2,6 [1] {10} |,2,7 [1] {10} |,2,8 [1] {10} |,2,9 [1] {10} | [1 4] {10} |,3,5 [1] {10} |,3,6 [1] {10} |,3,7 [1] {10} |,3,8 [1] {10} |,3,9 [1] {10} |].enlighened {10} | minus [1] {10} |,4,7 [1] {10} |,4,8 [1] {10} |,4,9 [1] {10} | 6 [1] {10} | [1, 5, 7] {10} |,5,8 [1] {10} | [1, 9] {10} | [1, 6] {10} |,6,8 [1] {10} |,6,9 [1] {10} | proposal [1] {10} |,7,9 [1] {10} |,8,9 [1] {10}) Take no x Cattle, the absolute positive solution CodePudding user response:
reference 13 floor assky124 reply: 13333991133 through Yes, three Numbers before there can be no repeat of the CodePudding user response:
refer to the second floor jx315425246 response: [345678] "^ 1 \ \ d {1} $" Could you tell me what these things mean? CodePudding user response:
references the 19th floor weixin_45949073 response: Quote: refer to the second floor jx315425246 response: [345678] "^ 1 \ \ d {1} $" Could you tell me what these things mean? ^ locator, starting from the first comparison, a phone number of the first 1, the second is: 345678 the Numbers, the third can all the Numbers 0-9, 8 bits with third, behind the $to the end of the 11th, terminator, this string is only 11 CodePudding user response:
So limited phone period of cough up Matching the first three digits can be sure is the second and third placenullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull