0

How can I combine these two so my string only matches if it has at least one large letter and at least one number in it

return Regex.IsMatch(string, 
                @"\A(?=\P{Lu}*\p{Lu})(?=\P{Ll}*\p{Ll})\p{L}+\z"); 
//but this works only with Big and small Letter, i dont know how I include the numbers

"^[0-9]+$" //Numbers

@"\A(?=\P{Lu}*\p{Lu})(?=\P{Ll}*\p{Ll})\p{L}+\z") 
//Letters which must receive at least one large
Sangram Shivankar
  • 3,535
  • 3
  • 26
  • 38
J.Yeah
  • 1
  • 1
  • 3
    It would be awesome if you could provide a [mcve] with a number of sample inputs and sample outputs that match those sample inputs. – mjwills Apr 19 '18 at 10:31
  • Does it *have* to be a regex? Why not simply `stringValue.Any(Char.IsNumber);` or `stringValue.Any(Char.IsDigit);`? – Corak Apr 19 '18 at 11:31
  • Does this answer your question? [Check if a string has at least one number in it using LINQ](https://stackoverflow.com/questions/1540620/check-if-a-string-has-at-least-one-number-in-it-using-linq) – xdtTransform Dec 02 '19 at 09:52

1 Answers1

0

Slightly adapted from another answer: (?=.*[0-9])(?=.*[A-Z])([A-Z0-9]+)

Fiddle with this on Regex101 or check the related answer

ccalboni
  • 12,120
  • 5
  • 30
  • 38