Article
1489
Problem
A reader described the following situation:
"I have a problem with the delimited text driver, when the input has attributes written in all capital letters and I need to convert them to title case. I have managed to change attributes with just one word to "Title Case" using reformat in Transformation policy, but some attibutes have more than one word. For example, Firstnames = "JOHN PETER"
goes to = "John peter" using reformat.
How do I detect the space and change the second, third, etc. words' first
letters to uppercase? Should I write a Input transformation policy using XSL template that converts a string from "ALL CAPITAL LETTERS" to "Title Case"?"
And here's the response from Lothar Haegar ...
Solution
If you can live with a less than 100%-solution, something like this
might work for you:
<do-reformat-op-attr name="UPPERCASE">
<arg-value>
<token-replace-all regex="\ba" replace-with="A">
<token-replace-all regex="\bb" replace-with="B">
<token-replace-all regex="\bc" replace-with="C">
[D,E,F...]
<token-lower-case>
<token-local-variable name="current-value"/>
</token-lower-case>
[another 23x...]
</token-replace-all>
</token-replace-all>
</token-replace-all>
</arg-value>
</do-reformat-op-attr>
Note that "\b" matches word boundaries. Take a look at the following reference; it helped me a lot:
http://www.regular-expressions.info/reference.html.





0