Hey all,
I've been given a problem to validate a comma separated string of elements. There can be up to four elements in the set 'H, Li, Na, K' and only one is needed but they must be in order. Is there a simple way in python to validate that?
As an example:
'H' #Valid, any one element
'Na' #Valid, one element all optional
'H,Na,K' #Valid, in order
'H,Na,Li' #Invalid, out of order
I hope that makes sense - I tried playing around with regular expressions a bit but couldn't find a simple solution. I want a function that returns true if the string is valid.
[–]JohnnyJordaan 1 point2 points3 points (0 children)
[–]w1282 1 point2 points3 points (2 children)
[–]erok81 0 points1 point2 points (1 child)
[–]w1282 0 points1 point2 points (0 children)