Skip to main content
Participating Frequently
August 26, 2010
Answered

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

  • August 26, 2010
  • 1 reply
  • 387 views

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 has been closed for replies.
    Correct answer JR__Bob__Dobbs

    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.

    1 reply

    JR__Bob__DobbsCorrect answer
    Inspiring
    August 26, 2010

    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.

    pwizzardAuthor
    Participating Frequently
    August 26, 2010

    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.