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

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:

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

results in:

23456789
234<5678
234

many thanks!
LVL 1
paddycobbettAsked:
Who is Participating?
 
mkishlineConnect With a Mentor Commented:
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>

or

#Replace(Mid("1234<abcde", 2, 9),'<','&lt;')#<br>
0
 
mankowitzConnect With a Mentor Commented:
Is it possible that it is thinking that the <a is the beginning of an html tag?
0
 
paddycobbettAuthor Commented:
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
0
 
paddycobbettAuthor Commented:
You're quite right both of you, hadn't occured to me that it was the browser's ill doing. Thanks guys!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.