I've got a file formatted like this:
3 name1
2 name2
1 name3
The space between the number and the name can be one or several spaces, or any number of tabs.
I'm trying to find a way to match this line with a regex and extract the number and the name in a list or tuple.
I could write this in several lines, but I'd rather have one clean line that can both recognize tabs and whitespace and give me my values. I've been unsuccessful in doing that.
edit: I've tried using re.search('^[\d]+[\s|\t]+.*', line) to match any number of digits, either spaces or tabs and then anything. But this doesn't work - presumably because I'm not telling it what to extract for me.
[ ]does.|to be matched:bool(re.search('[\s|\t]+', ' | '))(that's a bunch of spaces with a|in the middle) givesTrue.|character always mean a literal in a character class? Or is this a bug in python's regex engine.