Hope that's useful! In terms of regex worth knowing offhand, I'd recommend learning what the basic characters are and how to use them i.e. [] {} () ^ $ . + * .... They get me by in 99% of situations.import re
item = 'l_primCovFeathers1AEnd_loc'
pattern = "([0-9][A-Z])"
match = re.search(pattern, item)
if match:
letter_number = match.group(0)
number_letter = letter_number[::-1]
new_item = item.replace(letter_number, number_letter)
print new_item
else:
print "NO MATCH: %s" % item
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2d95fadb-d4a4-4565-8510-60092ded3c6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Also, there is a re.sub() for doing regex substitutions
https://docs.python.org/2/library/re.html#re.sub
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPzKG6X1%3D%3D0Ea8CyU9RTNeZtZWdqek9epSHXhrEgLy6Aeqk_ew%40mail.gmail.com.
How do you know all that stuff??!! XD
Whenever you think “string manipulation” beyond the simple replace() or upper(), think “Regular Expressions” (aka “regex” or “re”) and you’ve got it. :)
How do you know all that stuff??!! XD
Wow, thanks. There is no way I would have found that on my own
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/78149903-8242-4c0b-9149-de988bb4044a%40googlegroups.com.
On Mon, Jan 4, 2016 at 10:32 PM Rudi Hammad <rudih...@gmail.com> wrote:How do you know all that stuff??!! XD
Wow, thanks. There is no way I would have found that on my ownAt one point, any of us would have asked the same question. I found the answers through searching or asking. Over time you just build up a ton of answers in your brain and become more and more productive.Basically... time.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.