Advertisement
5_2007-2008 String Manipulation #190858

Find text in tags

This is just a simple code to find the text in a tag. like, [tag] I'm a tag![/tag]

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
'=================InTag Function====================
'=================================
'(C) Jason Yong 2003
'=================================
'This function will find what text is in a tag, like [b]this[/b]
'it will return different values depending on the ReturnCode
'ReturnCode = 1 will return the text
' 2 will return where the first tag starts
' 3 will return where the text in the tag starts
' 4 will return where the tag ends.
'===================================================
Function InTag(Text As String, StartTag As String, EndTag As String, ReturnCode As Integer) As String
Dim t As Long
Dim r As Long
 For t = 1 To Len(Text)
 If Mid(Text, t, Len(StartTag)) = StartTag Then
  For r = t To Len(Text)
  If Mid(Text, r, Len(EndTag)) = EndTag Then
   If ReturnCode = 1 Or ReturnCode = 0 Then InTag = Mid(Text, t + Len(StartTag), r - (t + Len(StartTag)))
   If ReturnCode = 2 Then InTag = Str(t)
   If ReturnCode = 3 Then InTag = Str(t) + Len(StartTag)
   If ReturnCode = 4 Then InTag = Str(r - (t + Len(StartTag) + Len(EndTag)))
  End If
  Next
 End If
 Next
End Function
Original Comments (3)
Recovered from Wayback Machine