Hello there
I have an attribute with values concatenated, I am looking to add character for each value
Before Attributephoto1,photo2,photo3
looking to get this after :
attributehttp://photo1/text,http://photo2/text,http://photo3/text
Hello there
I have an attribute with values concatenated, I am looking to add character for each value
Before Attributephoto1,photo2,photo3
looking to get this after :
attributehttp://photo1/text,http://photo2/text,http://photo3/text
You can do this with a regular expression in a string replacer
The regular expression (photo\\d+) matches any occurrence of the word photo followed by one or more numbers
The replacement text then replaces the matched value with http:// followed by the matched group \\1 followed by /text
You can do this with a regular expression in a string replacer
The regular expression (photo\\d+) matches any occurrence of the word photo followed by one or more numbers
The replacement text then replaces the matched value with http:// followed by the matched group \\1 followed by /text
@ebygomm
Thanks for your response I am not getting the same results in all feature
let me share the exact value
Before
mdc_photo_mdc_e7669f_cdv_photo_011_1558001156719.jpg,mdc_photo_mdc_0403/textd8_cdv_photo_001_1581000976829.jpg,mdc_photo_mdc_f0f840_cdv_photo_001_1581000976829.jpg,mdc_photo_mdc_2/textecf29_cdv_photo_001_1581000976829.jpg
we should get this
http://mdc_photo_mdc_e7669f_cdv_photo_011_1558001156719.jpg/text,http://mdc_photo_mdc_0403/textd8_cdv_photo_001_1581000976829.jpg/text,http://mdc_photo_mdc_f0f840_cdv_photo_001_1581000976829.jpg/text,http://mdc_photo_mdc_2/textecf29_cdv_photo_001_1581000976829.jpg/text
the expression you shared not giving the right results
as you can see the values are separated by ", "
@ebygomm
Thanks for your response I am not getting the same results in all feature
let me share the exact value
Before
mdc_photo_mdc_e7669f_cdv_photo_011_1558001156719.jpg,mdc_photo_mdc_0403/textd8_cdv_photo_001_1581000976829.jpg,mdc_photo_mdc_f0f840_cdv_photo_001_1581000976829.jpg,mdc_photo_mdc_2/textecf29_cdv_photo_001_1581000976829.jpg
we should get this
http://mdc_photo_mdc_e7669f_cdv_photo_011_1558001156719.jpg/text,http://mdc_photo_mdc_0403/textd8_cdv_photo_001_1581000976829.jpg/text,http://mdc_photo_mdc_f0f840_cdv_photo_001_1581000976829.jpg/text,http://mdc_photo_mdc_2/textecf29_cdv_photo_001_1581000976829.jpg/text
the expression you shared not giving the right results
as you can see the values are separated by ", "
Well no, you need quite a different regular expression for the actual data :-)
I think this regex might work for you, if all your strings start with mdc and end in .jpg
(mdc.*?.jpg)
A python alternative, which may be safer if the image names are not reliably consistent but are always comma separated
import fme
import fmeobjects
def processFeature(feature):
attrlist = feature.getAttribute('attribute').split(',')
newlist = l'http://'+i+'/text' for i in attrlist]
feature.setAttribute("attribute", ','.join(newlist))
You could of course, also split the attribute with the comma, explode the list, append the characters that you need, then rebuild the attribute but it's a bit inefficient
@ebygomm
Thanks so mutch