Difference between revisions of "Python: regex"

From OnnoWiki
Jump to navigation Jump to search
(Created page with " def contains_alphanumeric( input): r=re.match('[0-9a-zA-Z]+', input) if r==None: return False else: return True")
 
 
Line 1: Line 1:
  def contains_alphanumeric( input):
+
==Hanya a-zA-Z dalam string==
     r=re.match('[0-9a-zA-Z]+', input)
+
 
 +
  def hanya_huruf( input ):
 +
     r=re.match('^[a-zA-Z]+$', input)
 
     if r==None:
 
     if r==None:
 
       return False
 
       return False
 
     else:
 
     else:
 
       return True
 
       return True
 +
 +
==Batas==
 +
 +
^ start string
 +
$ akhir string

Latest revision as of 23:07, 31 January 2017

Hanya a-zA-Z dalam string

def hanya_huruf( input ):
   r=re.match('^[a-zA-Z]+$', input)
   if r==None:
      return False
   else:
      return True

Batas

^ start string
$ akhir string