vendredi 8 mai 2015

Regex to segregate list of strings and regexs

I have python input list containing both strings and regexs.

str_regex = ['normal_string_1', ''^(?![_\-])[A-Za-z0-9\-_]+$', 'normal_string_2'] 

I need to segregate this list into list of strings and list of regexs. In summary below are input and required output.

Input :

['normal_string_1', ''^(?![_\-])[A-Za-z0-9\-_]+$', 'normal_string_2']

Output :

['normal_string_1', 'normal_string_2'], ['^(?![_\-])[A-Za-z0-9\-_]+$']

I am planning to form a regex to do this. Something like "Should contains only [A-Z] and [a-z]". Is this the best way to do it?

Aucun commentaire:

Enregistrer un commentaire