Need Help with RegEx and replacing stings in a html file

Omegarex

Member
Licensed User
Longtime User
Hello Everyone,

I am trying to use regex with replace to remove/edit tags in an html document I have my new app download.

I am using the code I found here and I know it works.

html = RegexReplace("<head>", html, "<boots>") <-- this code works

html = html.Replace("/<head>(.*?)<\/head>/si", "") <-- This code doesn't work

Sub RegexReplace(Pattern As String, Text As String, Replacement As String) As String
Dim m As Matcher
m = Regex.Matcher(Pattern, Text)
Dim r As Reflector
r.Target = m
Return r.RunMethod2("replaceAll", Replacement, "java.lang.String")
End Sub

I believe the regex code doesnn't work because the search is going accross multiple lines of html. I use the regex /<head>(.*?)<\/head>/si in php and it works fine.

I would really appreciate help from any on you here.
 

Bruce Axtens

Active Member
Licensed User
Longtime User
Erel, this works for me in B4J and it's very helpful. However, it would be good if DOTALL could be added to the B4J Regex object. Could this be added to the list of updates for the next distribution?
 
Upvote 0
Top