-
I am making an HTML editor which is able to load html files. In order to load it correctly I need to detect what's between certain tags, such as the title and stuff. What I need is a function that will make everything lowercase which is between several less-than and grater-than symbols, yet ignores whatever is between quotations ("). I.e.
<this is all lowercase "BuT ThIs iS IgNoReD" this is still lowercase> ThIs iS IgNoReD, ToO <yet again this is lowercase>
Can anyone help?
-
I'm not sure what you want to do, when i looked at your example, well here's some functions for you
Code:
Lcase(text) will convert it lowercase
Ucase(text) will convert it uppercase
instr(text,d) will search for d in text
instr(x,text,d) will search for d in text, starting from x
mid(text,x) will return the rest of text from position x
mid(text,x,l) will return a part of a string starting from x and with the length l or shorter if in text is too short.
-
It's difficult to explain, but all I need is for a sub or function that will go through a string and convert everything to lowercase EXCEPT for whatever's between > and < and " and ".
The example I gave in the last post illustrated what I need, but if you don't have any HTML experience then it becomes a little difficult to understand...
I'll just start over here...
I am building an HTML editor which splits up an HTML file into its respective parts, ie the title and body. I only want to return what's BETWEEEN the <TITLE> and </TITLE> tags and the <BODY> and </BODY> tags. I've already made a function that would do that, except for the fact that I may tell it to look between <BODY> and </BODY> but the file may contain <Body> and </Body> or even <body> and </body>. This won't allow me to load the file correctly. I want to make whatever's between the < and > lowercase, yet leave alone whatever's between " and ". An example would be the body tag. The body tag usually contains a background attribute, which holds the filepath in quotations ("). The filepath MUST be the proper case, or it would be unable to locate the file. And I cannot make whatever's outside the < and > tags lower case or it would cause all the normal text to be lowercase.
I hope I've explained this will enough, I'm not that good at specifics and stuff like that. And strings are definitely not my best area. Actually, nothing's my best area.
Please help if you can, and denniswrenn, you know what I want, you think you can help me clarify?
-
Is this what you mean?
I made this to change the text to Ucase in my test as the example you gave doesn't have any text to change...
It's a very simple example and as I mention it won't take account of nested "<". If thats important then you should be able to modify it yourself. I don't know HTML so I can't tell if it is relevant.
Regards
Paul Lewis
Code:
make controls called txtSrc (Text), txtDest (Text), cmdDoIt (button). Paste the text into txtSrc and press the button.
Private Sub cmdDoIt_Click()
txtDest.Text = Parse(txtSrc.Text)
End Sub
Public Function Parse(srcText As String) As String
' takes no account of mismatched <> or unfinished " chars
' looks for text between <> BUT NOT between "" and changes it to
' lower case
Dim mySrc, myDst, tmp As String
Dim bracketCount As Integer
mySrc = srcText
Dim c As Long
Dim inQuote As Boolean
bracketCount = 0
inQuote = False
For c = 1 To Len(mySrc)
tmp = Mid(mySrc, c, 1)
Select Case tmp
Case Is = "<"
myDst = myDst & tmp
bracketCount = bracketCount + 1
Case Is = ">"
myDst = myDst & tmp
bracketCount = bracketCount - 1
Case Is = Chr$(34) ' easier to read than """
myDst = myDst & tmp
inQuote = Not inQuote
Case Else
If (bracketCount > 0) And Not inQuote Then
myDst = myDst & LCase(tmp)
Else
myDst = myDst & tmp
End If
End Select
Next
Parse = myDst
End Function