Wilcard matching substring in Python -
i new python , don't know how sub-string matches wildcard status string. trying timestamp next string:
sdc4-251504-7f5-f59c349f0e516894fc89d2686a0d57f5-1360922654.97671.data
i want "1360922654.97671" part out of string. please help.
if dots , dashes have specific function within string, can utilize this:
>>> s = "sdc4-251504-7f5-f59c349f0e516894fc89d2686a0d57f5-1360922654.97671.data" >>> s.rsplit('.', 1)[0].split('-')[-1] '1360922654.97671'
step step:
>>> s.rsplit('.', 1) ['sdc4-251504-7f5-f59c349f0e516894fc89d2686a0d57f5-1360922654.97671', 'data'] >>> s.rsplit('.', 1)[0] 'sdc4-251504-7f5-f59c349f0e516894fc89d2686a0d57f5-1360922654.97671' >>> s.rsplit('.', 1)[0].split('-') ['sdc4', '251504', '7f5', 'f59c349f0e516894fc89d2686a0d57f5', '1360922654.97671'] >>> s.rsplit('.', 1)[0].split('-')[-1] '1360922654.97671'
this work strings in form:
anything-whatyouwant.stringwithoutdots
python
No comments:
Post a Comment