python
python
- Started
- Last post
- 2 Responses
- ukit
Any Python programmers here?
Trying to figure out what would be the best way to parse a block of text, separate out image links and wrap them in a
tag. Kind of like posting images on this site.
- twokids0
you may have an easier time finding someone by going to Blender Artist's Forum. A lot of Blender users know Python since (I think) Blender was written with Python (I am not a coder)
- jasonistaken0
Easiest way to accomplish this is with a regex replace with a callback method.
re.sub allows you to pass a function as the replacement paramter.
Here's a simple example from the manual:>>> def dashrepl(matchobj):
... if matchobj.group(0) == '-': return ' '
... else: return '-'
>>> re.sub('-{1,2}', dashrepl, 'pro----gram-files')
'pro--gram files'You should be able to figure out the rest.