Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6489 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have a text field where I want to be able to remove any carriage returns which are at the end of the text (while keeping carriage returns which are in the middle). To get rid of one is easy:

case(right(field;1)= "¶" ; left (field;length(field)-1)

However, there may be more than one carriage return at the end of the text. It is quite common to have 2 or 3, but on occasions there have been 20+.

So, is there a tidy way to remove all these extra carriage returns using a calculation?

An example of the text in the field (using ¶ as a carrriage return):)

"Price Guide: £20¶

double £40¶

suite $80¶

¶"

In the above text example I would want to remove the final four paragraph characters.

Posted (edited)

I have a recursive custom function to do just that.

xCF_RemoveFormat_Full ( text )

Let( [ Format = Trim ( TextFormatRemove ( If ( Right ( Text ; 1 ) = "¶" ; Replace ( Text ; Length ( Text ) ; 1 ; "" ) ; Text ) ) )



];



If ( Right ( Format ; 1 ) = "¶" ; xCF_RemoveFormat_Full ( Format ); Format ) )

Edited by Guest
Posted

Those using v7 can also use the following which was originally posted by comment back in '05.

That's a neat idea.

Or you could use PatternCount() to deal only with the last occurence, something like:

Let ( [

crRun = "����������" ;

textCR = text & crRun ;

last = PatternCount ( textCR ; crRun ) ;

pos = Position ( textCR ; crRun ; 1 ; last )

] ;

Left ( textCR ; pos - 1 )

)

Note: n carriage returns in 'crRun' will remove up to n-1 carriage returns - always at the end.

full topic can be found at: http://fmforums.com/forum/showtopic.php?tid/168001/post/168343

Posted

Thanks for that solution strangler. Never knew could do recursive custom functions! Has opened up a whole new world of possibilities!

This topic is 6489 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.