473,386 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

RegExp: Replacing with submatch

I'm sure this isn't difficult, but it's Friday afternoon (!).

I'm trying to use a regular expression to match html tags in a string
and convert them to lower case. It's the RegExp object that I'm
struggling with rather then expression syntax.

So far I have this ('HELP!' denotes where I'm stuck):

private function recoverHTML(sHtml)
dim oRegExp
set oRegExp = new RegExp
oRegExp.IgnoreCase = False
oRegExp.Global = True
oRegExp.Pattern = "<(.*?)>"
sHtml = oRegExp.Replace(sHtml, HELP!)

set oRegExp = nothing
end function

I'm thinking of something like this:

"<" & lcase($1) & ">"

What syntax do I need here?

Thanks!

Drew

Jul 19 '05 #1
3 4999
DrewM wrote:
I'm thinking of something like this:
"<" & lcase($1) & ">"


Okay, I guess I should've just tried harder.

"<$1>" did the job. I also fixed my regexp to account for the closing slash.

oRegExp.Pattern = "<(/?.*?)>"
sHtml = oRegExp.Replace(sHtml, lcase("<$1>"))

However, it looks like the lcase() is applied before the submatch is
substituted, so it remains upper case.

Any ideas?

Drew

Jul 19 '05 #2
"DrewM" <bo***@doesntexist.com> wrote in message
news:eM**************@TK2MSFTNGP09.phx.gbl...
DrewM wrote:
I'm thinking of something like this:
"<" & lcase($1) & ">"
Okay, I guess I should've just tried harder.

"<$1>" did the job. I also fixed my regexp to account for the closing

slash.
oRegExp.Pattern = "<(/?.*?)>"
sHtml = oRegExp.Replace(sHtml, lcase("<$1>"))

However, it looks like the lcase() is applied before the submatch is
substituted, so it remains upper case.

Any ideas?


<%
Dim s,re
s = "<StRoNg>Now</sTrOnG> is the <EM>hour</em> of our discontent..."
Set re = New RegExp
Function crf(m,p,s)
crf = LCase(m)
End Function
With re
..Global = True
..Pattern = "<[^>]+>"
Response.Write .Replace(s,GetRef("crf"))
End With
%>

http://msdn.microsoft.com/library/en...ting121399.asp

HTH
-Chris Hohmann
Jul 19 '05 #3
Chris Hohmann wrote:
However, it looks like the lcase() is applied before the submatch is
substituted, so it remains upper case.

<%
Dim s,re
s = "<StRoNg>Now</sTrOnG> is the <EM>hour</em> of our discontent..."
Set re = New RegExp
Function crf(m,p,s)
crf = LCase(m)
End Function
With re
.Global = True
.Pattern = "<[^>]+>"
Response.Write .Replace(s,GetRef("crf"))
End With
%>

http://msdn.microsoft.com/library/en...ting121399.asp


Wow, you learn something new :)
Thank you very much, Chris. That's a massive help.

Drew

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Piotr | last post by:
Is there any way to split all merged words but www and e-mail addresses? I have regexp preg_replace("/(\.)(])/", "\\1 \\2", "www.google.com any,merged.words mymail@domain.com") it give me...
7
by: Alex | last post by:
Hi group, I am using the VBScript RegExp object from an ASP-Page and I got the following debugger output, when calling the Replace() method: "First-chance exception at 0x77e97c5c in...
2
by: Colin Steadman | last post by:
I'm trying to setup a function that will remove any character from a string which is NOT either a space, a-z or 0-9. I'm using a Regular Expression to do this. I'm almost there but I cant get...
6
by: Oliver Spiesshofer | last post by:
Hi, I would like to replace all strings in a table with regexp: the strings contain the substring "-na", and I would like to replace the whole table field with the original content but without...
4
by: lorinh | last post by:
Hi Folks, I'm trying to strip C/C++ style comments (/* ... */ or // ) from source code using Python regexps. If I don't have to worry about comments embedded in strings, it seems pretty...
1
by: redryderridesagain | last post by:
Using the Microsoft VBScript Regular Expressions 5.5 library in MS-Access VBA 6.3. I understand why the code below finds an occurance of the string "PC: blah blah blah A: BBB aaa B: BBB bbb C:...
4
by: drasko | last post by:
Hi all. I need to code simple and fast int regexp_match(char *regexp, char *string) function that will follow the expression regexp, and see if there is a matching in the string. If there is, it...
0
by: deathtospam | last post by:
I have a value, retrieved from a recordset, that contains any number of hyperlinks to a number. For example: <a href="123456">Hi</a<a href='334455'>Hola</a> What I need to do is parse the...
5
by: Davros9 | last post by:
Trying to get Regular Expressions working....... ---------------- Public Function SepString(InField As String) As String ''seperates on space and comma Dim RE As New RegExp Dim Matches As...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.