Skip to main content
Participating Frequently
August 26, 2010
解決済み

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

  • August 26, 2010
  • 返信数 1.
  • 388 ビュー

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

    このトピックへの返信は締め切られました。
    解決に役立った回答 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

    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.

    pwizzard作成者
    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.