Re: extracting a substring

2006-04-19 Thread rx
> and I want to extract the numbers 531, 2285, ...,359. > > One thing for sure is that these numbers are the ONLY part that is > changing; all the other characters are always fixed. > I'm not sure about what you mean by "always fixed" but I guess it means that you have n files with a fixed start

Re: extracting a substring

2006-04-19 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi, > I have a bunch of strings like > a53bc_531.txt > a53bc_2285.txt > ... > a53bc_359.txt > > and I want to extract the numbers 531, 2285, ...,359. > > One thing for sure is that these numbers are the ONLY part that is > changing; all the other characters are always f

Re: extracting a substring

2006-04-18 Thread Dale Strickland-Clark
You don't need a regex for this, as long as the prefix and suffix are fixed lengths, the following will do: >> "a53bc_531.txt"[6:-4] '531' >>> "a53bc_2285.txt"[6:-4] '2285' [EMAIL PROTECTED] wrote: > Hi, > I have a bunch of strings like > a53bc_531.txt > a53bc_2285.txt > ... > a53bc_359.txt >

Re: extracting a substring

2006-04-18 Thread Felipe Almeida Lessa
Em Ter, 2006-04-18 às 17:25 -0700, [EMAIL PROTECTED] escreveu: > Hi, > I have a bunch of strings like > a53bc_531.txt > a53bc_2285.txt > ... > a53bc_359.txt > > and I want to extract the numbers 531, 2285, ...,359. Some ways: 1) Regular expressions, as you said: >>> from re import compile >>> fi

Re: extracting a substring

2006-04-18 Thread Gary Herron
[EMAIL PROTECTED] wrote: >Hi, >I have a bunch of strings like >a53bc_531.txt >a53bc_2285.txt >... >a53bc_359.txt > >and I want to extract the numbers 531, 2285, ...,359. > >One thing for sure is that these numbers are the ONLY part that is >changing; all the other characters are always fixed. > >I

extracting a substring

2006-04-18 Thread [EMAIL PROTECTED]
Hi, I have a bunch of strings like a53bc_531.txt a53bc_2285.txt ... a53bc_359.txt and I want to extract the numbers 531, 2285, ...,359. One thing for sure is that these numbers are the ONLY part that is changing; all the other characters are always fixed. I know I should use regular expressions,