[ create a new paste ] login | about

Link: http://codepad.org/lpuqkXtd    [ raw code | output | fork ]

Python, pasted on Sep 8:
1
2
3
4
5
6
7
8
9
10
import re

strings = ["Alpha_beta_Gamma", "Alpha_Beta_Gamma"]
pattern = r'^[A-Z][a-z]*(?:_[A-Z][a-z]*)*$'

for s in strings:
    if re.match(pattern, s):
        print s + " conforms"
    else:
        print s + " doesn't conform"


Output:
1
2
Alpha_beta_Gamma doesn't conform
Alpha_Beta_Gamma conforms


Create a new paste based on this one


Comments: