Skip to main content

Hello everybody,

 

 

My problem : I have a "Description" attribute which contains text with length variable. The lenght is greater than 2000 characters. For each feature of the "Description" attribute, I want to replace all spaces after every 80 characters with "LF" (new line).

 

 

So I thank use StringReplacer to write a regular expression to calculate 80 characters intervals and identify the space after each 80 characters. Then I could have replace this by LF.

 

 

I helped myself with these topics on the forum:

 

- https://knowledge.safe.com/questions/51531/how-do-i-find-the-first-space-after-the-19th-chara.html

 

- https://knowledge.safe.com/questions/51514/splitting-attributes-by-number-of-words.html

 

- https://knowledge.safe.com/questions/40715/count-the-number-of-characters-and-numbers-in-a-gi.html

 

 

But I d'ont success it. Maybe I don't really understand explanations....

 

 

Do you have any leads ?

 

 

Thank you so much !

 

 

 

 

 

You can use the TextWrapper custom transformer from the FME Hub, followed by a ListConcatenator to insert a LF between all the resulting list items.


Couldn't you just use Takashi's solution in the previous example, creating an attribute with the following:

@ReplaceRegEx(@Value(text),(.{80,}?)\\s,\\1

)

where text is the name of the attribute containing the original string?


Thank you david_r and jdh for your help ! I don't test your proposition jdb but I keep your idea !

 

dvid_r your solution do what I want perfectly ! Thank you !!

 

 

 

 

 


Couldn't you just use Takashi's solution in the previous example, creating an attribute with the following:

@ReplaceRegEx(@Value(text),(.{80,}?)\\s,\\1

)

where text is the name of the attribute containing the original string?

Thank you jdh for your help ! I don't test your proposition jdb but I keep your idea !


Couldn't you just use Takashi's solution in the previous example, creating an attribute with the following:

@ReplaceRegEx(@Value(text),(.{80,}?)\\s,\\1

)

where text is the name of the attribute containing the original string?

Funny, doesn't work for me. Rather than inserting newlines it seems to simply remove the space between the words every ~80 characters. Tested with FME 2020: regex_wordwrap.fmwt


Funny, doesn't work for me. Rather than inserting newlines it seems to simply remove the space between the words every ~80 characters. Tested with FME 2020: regex_wordwrap.fmwt

Bad formatting on my part. Put the closing parenthesis on a new line

@ReplaceRegEx(@Value(text),(.{80,}?)\\s,\\1

)


Bad formatting on my part. Put the closing parenthesis on a new line

@ReplaceRegEx(@Value(text),(.{80,}?)\\s,\\1

)

Devious regex... ;-)


Reply