repeating regular expressions in one string

  • Thread starter =?iso-8859-4?Q?Shane?=
  • Start date
?

=?iso-8859-4?Q?Shane?=

Hi folks,

I'm new to regular expressions (and a novice at Python) but it seems to be the tool I need for a particular problem. I have a bunch of strings that looks like this:

'blahblah_sf1234-sf1238_blahblah'

and I would like to use the re module to parse all the 'sfXXXX' parts of the string. Each 'sfXXXX' needs to be its own string when I am through. How do I compile a regular expression that looks for more than one instance? Currently my expression looks like this:

myString = re.compile('sf[0-9][0-9][0-9][0-9]')

This works great for finding the first instance of 'sfXXXX'. I hope that was clear :)

Thanks,

Shane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top