So, I have a file full of IDs and names of various stores that I want to extract either the ID or the store name from.
I got the ID part of it pretty quickly, because they're fixed lengths and at the beginning of the string. The names, however, are variable lengths from 0-50 alphanumeric characters.
the format is:
12345-my store name-
12346-my Big 1 Store Name The Eleventh-
what I'm trying is:
Code:
import re
my_pattern = re.compile('-*-')
storelist = ['12345-my store name-', '12346-my Big 1 Store Name The Eleventh-']
for line in storelist:
my_store = my_pattern.search(storelist)
my_store.group()
this isn't how I actually plan to keep it, but I'm new to Python and trying to figure out how to make something like this work so I can write a function that returns a store name at a given position in the list.
What I am wrongly assuming is happening is that the pattern searches for most anything inside of '-'s, but this doesn't appear to be the case.
Instead, it will find a single '-' and print that.
How can I create a pattern that represents a '-', some variable amount of letters/numbers after it, and then another '-'?