Jump to content
Server Maintenance This Week. ×

CF to remove chars from text


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

Recommended Posts

Despite how hard I try I can't incorporate the logic of recursive functions into a working syntax, so any help is appreciated:

The task is to selectively remove from a return delimited list either a certain number of characters from the start of each line or up to a certain character (e.g. inderscore _).

I suppose that the logic should be something like the following pseudo-code (as if it was a script):)

1. Count the number of lines

2. Define the number of characters from start

3. Go to first line

4. Loop

5. Do Replace Function (String; From;To;"")

6. Go to next line

7. Exit Loop if Line > Number of Lines

Another thing would also be to be able to define the search character up to which chars will be deleted.

Can anyone help?

P.S. Help can also contain simple teaching/learning tips if people kindness is great..

Link to comment
Share on other sites

Custom functions are recursive, not iterative. So it might be better to:

1. Process the first value in the list;

2. If the list contains more than one value, call the function again with the remaining values as the parameter.

Link to comment
Share on other sites

To take a simple example of returning the first word of each item in the list:

FirstWords ( listOfValues )


Let ( [

item = GetValue ( listOfValues ; 1 ) ;

countValues = ValueCount ( listOfValues )

] ;

LeftWords ( item ; 1 )

&

Case (

countValues > 1 ;

¶ & FirstWords ( RightValues ( listOfValues ; countValues - 1 ) )

)

)

Link to comment
Share on other sites

This topic is 5085 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.