We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Mid function problem when "<" character is superceded by a letter

Medium Priority
Last Modified: 2013-12-24
Coldfusion: I'm getting bizarre behaviour with the Mid function which uses strings which include the "<" character. When the "<" is superceded by a NUMBER the function works as expected, however when it is superceded by a LETTER it cuts short the result. Take a look a the code below and the output i receive. I will award points to whoever can explain why the last example (with the letter superceding the "<") give the result that it gives:

#Mid("123456789", 2, 9)#<br>
#Mid("1234<56789", 2, 9)#<br>
#Mid("1234<abcde", 2, 9)#<br>

results in:


many thanks!
Watch Question

Is it possible that it is thinking that the <a is the beginning of an html tag?

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


It is true that the string i intend to substring is html, but i wouldn't have thought that the Mid function recognises that, i would have thought it just treats is as raw text right? or not? Even if i replace the a with a z such as:

#Mid("1234<zbcde", 2, 9)#

i get the same result. Any thoughts? and thanks for the response =)

B.T.W there are no problems with the opposite ">" tag
mankowitz is correct that it (the browser) thinks you're trying to use an html tag. If you view the source, you'll see that the remaining characters are present in the source code, they just don't appear on the page. Two options to solve this would include:
#HTMLCodeFormat(Mid("1234<abcde", 2, 9))#<br>


#Replace(Mid("1234<abcde", 2, 9),'<','&lt;')#<br>


You're quite right both of you, hadn't occured to me that it was the browser's ill doing. Thanks guys!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.