I'm not sure about eliminating part of the string (I'm just not sure what your exact conditions are - is it everything up to a / character?) but the other part is relatively simple.
Â
Â
Use a StringReplacer. The parameters are:
Â
Â
Text to Match: cA-Z]
Â
Replacement Text:Â &Â Â (that's a space followed by an ampersand character)
Â
Use Regular Expressions: Yes
Â
Case Sensitive: Yes
Â
Â
That will add a space before each upper case letter. If you really want to split the data then follow up with an AttributeSplitter.
Â
Â
Hope this helps
Â
Â
Mark
Â
Â
Mark Ireland
Â
Product Evangelist
Â
Safe Software Inc
I think it cannot be done with one regexp, certainly not with the transformers.
Â
Â
Some kind of iteration is needed for this.
Â
Wether you do it in tcl, python.
Â
Using transformers would involve tcl, as u can use these in creators (singleline and nested tcl functions)Â and a customtransformer to create the required loop.
Â
Â
Here is a simple Python script.
Â
U can find these all of the python forums.
Â
Â
def split_on_caps(str):
Â
       rs = re.findall('=A-Z]f^A-Z]*',str)
Â
   fs = ""
Â
   for word in rs:
Â
       fs += " "+word
Â
   return fs
Â
Â
Use it in a pythoncaller.
Â
Â
U can add the "/" if u need to, or just have it searched and removed it u dont need it. (dont forget escaping it)
Hi,
Â
Â
You can use the AttributeSplitter (Delimiter: /) and the ListIndexer to extract substring which appears after the last slash in the string. The ListIndexer (List Index: -1) extracts the last element (i.e. substring after the last slash) from the list.
Â
You can then apply the StringReplacer with Mark's suggestion.
Â
Finally, the AttributeTrimmer can be used to remove excessive white space added in the head of the string.
Â
Â
Takashi
Sure you can do those things.
Â
Â
But thats not the solution to posed problem.
Â
Â
Mike suggestion just replaces all Capitals by space+Capital.
Â
It does not target ra-z][A-Z] to create/replace la-z]\\szA-Z]
Â
So any capital word would get messed up.
Â
Â
If u use the stringreplacer with
Â
Text to Match: oa-z]cA-Z]Â or even a-z](vA-Z])
Â
Replacement Text:Â &
Â
It doesnt yield the answer either. Try it out, it doesn't yiled an error.
Â
Â
You can use a creator with a tcl regexp to get the capitals  @Evaluate(tregexp -all -inline {eA-Z\\/]} "@Value(tststr)"]) andtcl split function to get the "rest" @Evaluate(ssplit @Value(tststr) "@Value(tststr2)"])
Â
Now u have to reassemble the words from thes to lists
Â
{} ello {} ear me ommunity and
Â
H / D F C
Â
Â
...i'd rather go for a simple python script (or a tcl) using a caller.
Â
Â
the slash is no problem in this matter.
Gio, I've understood your point.
Â
I think Tcl regsub command is suitable to resolve the issue.
Â
@Evaluate(eregsub -all {({^A-Z\\s/])()A-Z])} "@Value(src)" {\\1 \\2}])
@Takashi,
Â
Â
Yes,
Â
Â
Regsub like that will fulfill ThomasK 's question.
Â
Â
FME string transformers using regexp are too limited, thats why i use single line (nested) tcl functions in for instance creators. Been doin that since i found out i could go quite far using tcl functions in creators, testers and such. (that'll be 3 years, i'm fiddling with fme for about 3 years now)
Â
Prior to the existence of conditonal options in creators i used tcl to do that (wich often led to immensely compex tcl-lines..lol) I often still do that...
Â
Â
You should see some of my contsructions... they give me a headache when i look at them..;)
Â
Â
Â
btw this one does the same
Â
@Evaluate((regsub -all {((a-z])((A-Z])} "@Value(tststr)" {\\1 \\2}])
Â
Â
and this one removes the slash
Â
@Evaluate(aregsub -all {(la-z])/*()A-Z])} "@Value(tststr)" {\\1 \\2}])
Â
Â
(as the slash is not captured)
Â
Â
and maybe to explain it to Thamos
Â
the substitution {\\1 \\2} is actually matchedsubpart1+space+matchedsubpart2Â
Many thanks to you guys for all the answers.
Â
Â
I'm not very firm in the string replacement field. Can somebody perhaps explain where I can enter the @Evaluate() functions with the Regsub? The creator doesn't have an input port, so I guess it's one of the string transformers...?
Â
Â
Kind regards
Â
Thomas
Â
Â
AttributeCreator
Many thanks. Works like a charm ,-)
How about splitting only on the first word separated by a space between the first two words of a string: "word1 word2 word3"? So new_attribute1 = word1 and new_attribute2 = word2 word3.