Skip to main content
Participating Frequently
Aug 26, 2010 12:50 PM UTC
Answered

Replace ~The with The and moved to the start of a line

I'm redoing an existing web site in ColdFusion and mysql that was originally created in php and mysql, so the database already exists. There is a table of titles which show in the database as "Church: The Figure of the Flock~The", though on the page are displayed as "The Church: The Figure of the Flock" this is so the title is ordered by Church and not The. So I need to strip out ~The and insert The at the start. I would appreciate it, if someone could point me in the right direction how to achieve this. The same applies to ~A. Thanks

    This topic is closed to new replies. Start a new post to keep the conversation going.
    JR__Bob__DobbsCorrect answer
    Inspiring
    Aug 26, 2010 1:20 PM UTC

    You could use CF's list functions to split the string up treating the tilde character as the list's delimiter.


    Here is a quick sample.

    <cfset title="Church: The Figure of the Flock~The">

    <cfset fixedTitle=ListLast(title, "~") & " " & ListFirst(title, "~")>

    You might wrap this into a user defined function that checks for the existence of the tilde character in the title string.

    2 replies

    JR__Bob__DobbsCorrect answer
    Inspiring
    Aug 26, 2010 1:20 PM UTC

    You could use CF's list functions to split the string up treating the tilde character as the list's delimiter.


    Here is a quick sample.

    <cfset title="Church: The Figure of the Flock~The">

    <cfset fixedTitle=ListLast(title, "~") & " " & ListFirst(title, "~")>

    You might wrap this into a user defined function that checks for the existence of the tilde character in the title string.

    Translate
    pwizzardAuthor
    Participating Frequently
    Aug 26, 2010 2:40 PM UTC

    Thanks for you help, that seems to work, not all the titles have a tilde so I added a ListContains to find the ones that have and that works.

    Translate