<% Function Reggex(strString, strPattern, strReplace) Dim RE: Set RE = New RegExp With RE .Pattern = strPattern .Global = True .IgnoreCase = True Reggex = .Replace(strString, strReplace) End With End Function Function ReplaceChar(strString) fromDate="1-Jan-2000" toDate=date strString = Reggex(strString, "\[BusDate\]", ""&DateDiff("yyyy",fromDate,toDate)&"") 'This will give the output of 16 (being that it is 2016 now) 'However, what I need is to be able to type in the 2 dates. strString = Reggex(strString, "\[theDate:([^\]]+)\|(.*?)\]", ""&DateDiff("yyyy","$1","$2")&"") 'However, the output in this example, will give me 1 (ONE) ReplaceChar = strString End Function working = "[Busdate]" testing = "[theDate:1950|2016]" %> Working: <%=ReplaceChar(working)%><br /> Non-working: <%=ReplaceChar(testing)%>
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE