Skip to main content
Participant
May 1, 2006
Question

Split on Number

  • May 1, 2006
  • 2 replies
  • 324 views
Hi,

Could anyone explain how to split a string at the first number it comes to. The two halves can then be passed to a list or an array.

I've got several variables such as "Mar16", "June13" etc (dates) and I need to split it into "Mar" and "16" etc so I can increment the date by one ie Mar16 to Mar17.

TIA,

Simon
    This topic has been closed for replies.

    2 replies

    Inspiring
    May 1, 2006
    This is easier and handles last days of the month better.

    dayafter = DateAdd("d", 1, "Mar 16");
    Participating Frequently
    May 1, 2006
    There are many ways to do this sort of thing. Below is one example using various CF string functions.

    <cfset vDate = "Mar16">

    <cfset vNumPos = ReFind("[0-9]", vDate)>
    <cfset vMonth = Left(vDate, vNumPos-1)>
    <cfset vDay = Mid(vDate, vNumPos, Len(vDate))>

    <cfoutput>#vMonth#</cfoutput>
    <cfoutput>#vDay#</cfoutput>

    Phil