|
-
Jul 13th, 2003, 10:47 PM
#1
Thread Starter
Stuck in the 80s
[Resolved] RegEx Help
I've never worked with Regular Expressions in VB, but am pretty good with it in PHP.
What I need to do is get rid of <font>text here</font>, no matter what "text here" is.
In VB, the expression would be something like "/<font>(.*)</font>/", but that doesn't seem to work in VB.
Also, when I distribute this application, what files will I have to include for the Reg Expression Library?
Last edited by The Hobo; Jul 23rd, 2003 at 03:45 PM.
-
Jul 13th, 2003, 11:03 PM
#2
Thread Starter
Stuck in the 80s
This is what I'm trying:
VB Code:
Option Explicit
Private Sub cmdConvert_Click()
Dim strHTML As String
Dim regEx As RegExp
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
strHTML = txtHTML.Text
strHTML = Replace(strHTML, "<html>", "", , , vbTextCompare)
strHTML = Replace(strHTML, "</html>", "", , , vbTextCompare)
regEx.Pattern = "<font>(.*)</font>"
strHTML = regEx.Replace(strHTML, " this was replaced ")
rtfDisplay.Text = strHTML
Set regEx = Nothing
End Sub
And it seems to replace all instances, but it only shows " this was replaced " once, instead of for all occurances?
-
Jul 14th, 2003, 11:47 AM
#3
Thread Starter
Stuck in the 80s
Anybody? 
I really just need to know how to access the wildcards. In PHP, "\\1" would access the value of the first wildcard in the replacement, but that doesn't work here.
I've searched the forums and the web, but haven't found anything.
-
Jul 14th, 2003, 11:53 AM
#4
can you use RegEx in vb6 then? cuz i've used it in vb.net / C# / javascript , but i've never heard of it being used in vb6 and i cant seem to find a way to reference it. if you are trying to convert a html file to a text file ( minus the html ) you can use Doument.documentelement.InnerText
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Jul 14th, 2003, 12:02 PM
#5
Thread Starter
Stuck in the 80s
Yes, you can use it in VB6. No, I am not trying to do that.
-
Jul 14th, 2003, 12:03 PM
#6
Thread Starter
Stuck in the 80s
To use it in VB6, you must include a reference to Microsoft VBScript Regular Expressions 5.5 (or 1.0).
Then use code similar to what I have posted above.
-
Jul 14th, 2003, 01:53 PM
#7
Frenzied Member
You are missing one small thing (?) mark.
Code:
regEx.Pattern = "<font>.*?</font>"
-
Jul 23rd, 2003, 03:44 PM
#8
Thread Starter
Stuck in the 80s
Thanks. I ended up just doing a series of replaces, but I'll probably try to hook up the expressions again later, if I continue the project.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|