vendredi 17 février 2017

how to create a regexp pattern with repeats in python

I have strings like "hereis-SSN1234_12-12", "from-SSN2343_SSN3223-21", "SSN1235_SSN021_SSN3122-123", I would like to extract substrings to be:

"hereis-SSN1234_12-12" -->"SSN1234_12" 
"from-SSN2343_SSN3223-21" --> "SSN2343_SSN3223"
"SSN1235_SSN021_SSN3122-123" --> "SSN1235_SSN021_SSN3122"
"here: SSN1_SSN022_SSN3223_SSN9233-323" --> "SSN1_SSN022_SSN3223_SSN9233"

SSN parts could be repeated multiple times.

how to construct a single regexp pattern to find the matched substring?

Aucun commentaire:

Enregistrer un commentaire