Sorry if I get something completely wrong here but why don't you do this?:
arr = [u'Bricks_|_BRICKS_1', u'_BRICKS_2', u'_BRICKS_3', u'_BRICKS_4',
u'Bricks_|Small_BRICKS_1']
arrNew = []
for a in arr:
arrNew.append(a.split("Bricks_|")[-1])
print arrNew
"""
gives [u'_BRICKS_1', u'_BRICKS_2', u'_BRICKS_3', u'_BRICKS_4',
u'Small_BRICKS_1']
"""
hope this helps,
seb
On Wed, Apr 8, 2009 at 10:12 PM, Tucker <[email protected]> wrote:
>
> Hey again! I was wondering if you could perhaps throw some of that
> tokenizing help again my way. I'm having trouble getting the right
> selection to be able instance in objects. My problem is this, i have
> several objects parented to a group. Now my problem is that the list
> of the children comes out as this -
>
>
> [u'Bricks_|_BRICKS_1', u'_BRICKS_2', u'_BRICKS_3', u'_BRICKS_4',
> u'Bricks_|Small_BRICKS_1']
>
> Now in order for my other peice of code to work i need to tokenize
> every object in the string so that the list no longer has the group
> parent in the name, because the group part of the name will throw an
> error my way saying invalid selection. For example, instead of the
> list above i need the list to be with out the 'Bricks_|' so it looks
> some thing like this -
>
>
> [u'_BRICKS_1', u'_BRICKS_2', u'_BRICKS_3', u'_BRICKS_4',
> u'Small_BRICKS_1']
>
> I've tried tokenizing this by using a variation of what you gave me
> which is this -
>
> reg = re.compile("([^.]+)\|(\w+)$")
>
> But i can only seem to get this to work on one variable at a time and
> it returns the results in the form of a list which is this -
>
> (u'Bricks_', u'_BRICKS_1')
>
> But i was wondering if you know of any way to loop through the
> original children list and be left with only '_Bricks_1' and to get
> rid of the group name? Currently any loops i'm trying don't seem to
> work and i'm at a loss on how to do it. Any help you can give would be
> greatly appreciated.
>
> Tucker
>
>
> >
>
--
Sebastian Schoellhammer
Sr. Technical Artist
Square Enix LTD
www.square-enix.com
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---