On Wed, 30 Sep 2015 23:30:47 +, Denis McMahon wrote:
> On Wed, 30 Sep 2015 11:34:04 -0700, massi_srb wrote:
>
>> firstly the description of my problem. I have a string in the following
>> form: .
>
> The way I solved this was to:
>
> 1) replace all the punctuation in the string with spa
On Oct 2, 2015 12:35 AM, "Denis McMahon" wrote:
>
> On Thu, 01 Oct 2015 01:48:03 -0700, gal kauffman wrote:
>
> > items = s.replace(' (', '(').replace(', ',',').split()
> >
> > items_dict = dict()
> > for item in items:
> > if '(' not in item:
> > item += '(0,0)'
> > if ',' not in
On Thu, 01 Oct 2015 15:53:38 +, Rob Gaddi wrote:
> There's a quote for this. 'Some people, when confronted with a problem,
> think “I know, I'll use regular expressions.” Now they have two
> problems.'
I actually used 2 regexes:
wordpatt = re.compile('[a-zA-Z]+')
numpatt = re.compile('[0-
On Thu, 01 Oct 2015 01:48:03 -0700, gal kauffman wrote:
> items = s.replace(' (', '(').replace(', ',',').split()
>
> items_dict = dict()
> for item in items:
> if '(' not in item:
> item += '(0,0)'
> if ',' not in item:
> item = item.replace(')', ',0)')
>
> name, raw_
On Wed, 30 Sep 2015 11:34:04 -0700, massi_srb wrote:
> Hi everyone,
>
> firstly the description of my problem. I have a string in the following
> form:
>
> s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
>
> that is a string made up of groups in the form 'name' (letters only)
> plus possib
My example will give false positive if there is a space before a comma. Or
anything else by the conventions in the original string.
I tried to keep it as simple as I could.
If you want to catch a wider range of values you can use *simple* regular
expression to catch as much spaces as you want.
On O
On 2015-10-01 01:48, gal kauffman wrote:
> items = s.replace(' (', '(').replace(', ',',').split()
s = "name1 (1)"
Your suggestion doesn't catch cases where more than one space can
occur before the paren.
-tkc
--
https://mail.python.org/mailman/listinfo/python-list
items = s.replace(' (', '(').replace(', ',',').split()
items_dict = dict()
for item in items:
if '(' not in item:
item += '(0,0)'
if ',' not in item:
item = item.replace(')', ',0)')
name, raw_data = item.split('(')
data_tuple = tuple((int(v) for v in
raw_data.repla
On 9/30/2015 12:20 PM, Tim Chase wrote:
On 2015-09-30 11:34, massi_...@msn.com wrote:
I guess this problem can be tackled with regular expressions, b
... However, if you *want* to do it with
regular expressions, you can. It's ugly and might be fragile, but
##
On Wed, 30 Sep 2015 11:34:04 -0700, massi_srb wrote:
> firstly the description of my problem. I have a string in the following
> form: .
The way I solved this was to:
1) replace all the punctuation in the string with spaces
2) split the string on space
3) process each thing in the list to
On 2015-09-30 11:34, massi_...@msn.com wrote:
> firstly the description of my problem. I have a string in the
> following form:
>
> s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
>
> that is a string made up of groups in the form 'name' (letters
> only) plus possibly a tuple containing 1 or
On Wed, Sep 30, 2015 at 2:50 PM, Emile van Sebille wrote:
> On 9/30/2015 11:34 AM, massi_...@msn.com wrote:
>
>> Hi everyone,
>>
>> firstly the description of my problem. I have a string in the following
>> form:
>>
>> s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
>>
>> that is a string ma
On 9/30/2015 11:34 AM, massi_...@msn.com wrote:
Hi everyone,
firstly the description of my problem. I have a string in the following form:
s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
that is a string made up of groups in the form 'name' (letters only) plus
possibly a tuple containing
Hi everyone,
firstly the description of my problem. I have a string in the following form:
s = "name1 name2(1) name3 name4 (1, 4) name5(2) ..."
that is a string made up of groups in the form 'name' (letters only) plus
possibly a tuple containing 1 or 2 integer values. Blanks can be placed betwe
14 matches
Mail list logo