Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python - How to check if string is a HEX Color Code

import re
str = '#ffffff' # Your Hex

match = re.search(r'^#(?:[0-9a-fA-F]{3}){1,2}$', str)

if match:                      
  print 'Hex is valid'

else:
  print 'Hex is not valid'
Comment

PREVIOUS NEXT
Code Example
Python :: install re package python 
Python :: return result from exec python 
Python :: python check if there is internet 
Python :: install mamba conda 
Python :: import reverse_lazy 
Python :: run django app locally 
Python :: how to hit enter in selenium python 
Python :: python random number 
Python :: pandas print first column 
Python :: pytorch tensor add one dimension 
Python :: set cuda visible devices python 
Python :: select closest number in array python 
Python :: connect postgresql with python sqlalchemy 
Python :: how to split a string between letters and digits python 
Python :: docker compose command not found 
Python :: python system year 
Python :: dns request scapy 
Python :: export python pandas dataframe as json file 
Python :: hbox(children=(floatprogress(value= 
Python :: pandas left join 
Python :: update jupyter notebook 
Python :: python heart code 
Python :: blender python set object location 
Python :: random word generator python 
Python :: pip install torch error 
Python :: how to make computer go in sleep mode using pythn 
Python :: when did guido van rossum create python 
Python :: pandas Error tokenizing data. 
Python :: add column as index pandas 
Python :: how to convert dataframe to list in python 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =