473,785 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regular Expression Help

I'm somewhat new to regular expressions and am in need of assistance. I'd
like to match on any OBJECT, EMBED, or APPLET element nested inside an
<HTML> element. Would someone point me in the right direction for creating
such a regular expression or at least point me to the correct news group?

Kindest regards,
Michael
Mar 24 '06 #1
8 1574
Hi Michael,

I'm not that good with Regex, though I do confess to a strong
fascination for them, so I can't answer you outright. I'll work on it,
see if I can come up with something...

The best places to ask questions about Regular Expressions are :

1. There is a Regex group (not hosted by MSNews). It can be reached by
:
http://groups.google.com/group/regex?lnk=li

2. Regexadvice.com and RegexLib.com maintain forums where you can
usually ask questions on Regex Construction.

These are the main Newsgroups that the Regex Gurus monitor... I would
suggest posting there, for maximum response.

It is always useful when trying to construct a Regex, if you can
provide some sample text that you would like to match, and try to be as
specific as possible. For instance, would you like to match only the
OBJECT, EMBED etc. tags or everything between them as well...

Hope this helps,

Regards,

Cerebrus.

Mar 24 '06 #2
Michael,
Cerebrus is right, you might want to ask Reg Ex questions in a more
appropriate place.
That said I'll throw in my 2 cents ;-)
Instead of looking for a preformatted answer you'd be better of
learning how to do this from scratch, if you are serious about using
regular expressions.
Two resources I found very helpful when I started using Regular
Expression were these two:

Microsoft:
http://msdn.microsoft.com/library/de...ting051099.asp
Not that you are (or should be using) VBScript for anything besides old
server side ASP pages, but I found this article helpful since it
provided a very nice synopsis of Regular Expression, it is a handy
reference.

DevGuru:
http://www.devguru.com/Technologies/...ef/regexp.html
I love this site. Its a great quick reference.

So to help you along here is a Javascript example Regular Expression I
use to rip out entire HTML tags and their contents:
function removeTag( strInput, tagName )
{
var re = new RegExp("<"+ tagName +"(.|\n)*</"+ tagName +">", "g");
return strInput.replac e(re, "");
}

but this could also be done with Literal Notation (when the expression
will be fixed not variable like in the above example).
(here "tagName" is fixed as "s:Schema"...ca n you tell now that I'm
working with XML ;-) ):
function removeTag( strInput )
{
return strInput.replac e( /<s:Schema([\s\S]*)<\/s:Schema>/ig, "");
}

So just to show you how different to functions can be that do the same
thing!
Hope that gets you started ;-)

Mar 24 '06 #3
Michael Primeaux wrote:
I'm somewhat new to regular expressions and am in need of assistance. I'd
like to match on any OBJECT, EMBED, or APPLET element nested inside an
<HTML> element. Would someone point me in the right direction for creating
such a regular expression or at least point me to the correct news group?


[OoEeAa][BbMmPp][JjBbPp][EeLl][CcDdEe][Tt]?

///Peter
Mar 25 '06 #4
Hi Peter...

Your suggestion, though admittedly unorthodox, does not catch the EMBED
tag, but it can catch EMBEDT...

Just FYI,

Regards,

Cerebrus.

Mar 25 '06 #5
Cerebrus wrote:
Hi Peter...

Your suggestion, though admittedly unorthodox, does not catch the EMBED
tag, but it can catch EMBEDT...


Probably change the ? to *

///Peter
Mar 26 '06 #6
The following expression meets my requirements.

(?i)(((?<!')(?< !")(<\s*EMBED\s *[^>]+src\s*=[^<]+?(?<!/)\s*>[^*]+?<\s*/\s*EMBED\s*>)|( <\s*EMBED\s*[^>]+src\s*=[^/>]+/>))|((?<!')(?<! ")((<\s*OBJECT\ s*[^>]+classid\s*=\s*["']clsid:[^>]+?\s*(?<!/)\s*>[^*]+?<\s*/\s*OBJECT\s*>)| (<\s*OBJECT\s*[^>]+classid\s*=\s*["']clsid:[^/>]+/>))|((?i)(?<!') (?<!")(<\s*APPL ET\s*[^>]+code\s*=[^<]+?(?<!/)\s*>[^*]+?<\s*/\s*APPLET\s*>)| (<\s*APPLET\s*[^>]+code\s*=[^/>]+/>))))

Regards,
Michael

"Michael Primeaux" <mj********@nos pam.msn.com> wrote in message
news:ub******** ******@TK2MSFTN GP12.phx.gbl...
I'm somewhat new to regular expressions and am in need of assistance. I'd
like to match on any OBJECT, EMBED, or APPLET element nested inside an
<HTML> element. Would someone point me in the right direction for creating
such a regular expression or at least point me to the correct news group?

Kindest regards,
Michael

Mar 29 '06 #7
Congrats !

It does seem a bit long, but if it works... then great !

Regards,

Cerebrus.

Mar 30 '06 #8
Wow!
....um, it seems you have all simply ignored my post.

Using the function I posted:

function removeTag( strInput, tagName )
{
var re = new RegExp("<"+ tagName +"(.|\n)*</"+ tagName +">", "g");
return strInput.replac e(re, ""); //this can be anything you like,
doesn't have to be a replace
}

you can match those tags easily (and it matches anything in the tag or
ON the tag such as attributes):
removeTag( StringToSearch, "EMBED");
removeTag( StringToSearch, "OBJECT");
removeTag( StringToSearch, "APPLET");

The "remove" part of the function is simply what I've done with the
matched item. You can do anything you like with the match. Of course
you didn't state what you were doing, only that you needed to match on
those tags.

What will happen to your regular expression if I added a new attribute
to the tag?
I think if you write expressions this complicated and specific you'll
quickly start to hate Reg Expr. ;-)

But hey I'm only here to help, good luck!

Mar 30 '06 #9

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

Similar topics

5
2534
by: Bradley Plett | last post by:
I'm hopeless at regular expressions (I just don't use them often enough to gain/maintain knowledge), but I need one now and am looking for help. I need to parse through a document to find a URL, and then reconstruct another URL based on it. For example, I need to scan a web page looking for something like <a href="some_dir/list_20050815100225.csv">. I don't know in advance what the date/time in the file name will be. I need to take the...
4
3231
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go over each document, find out if it contains a header and/or a footer and extract only the main content part. The headers and the footers have no specific format and I have to detect and remove them using a list of strings that may appear as...
10
3037
by: Lee Kuhn | last post by:
I am trying the create a regular expression that will essentially match characters in the middle of a fixed-length string. The string may be any characters, but will always be the same length. In other words, as the regular expression (....)($) matches the "4567" in the string "1234567", how would I create a similar regular expression that only matches the "45" in the same string. The same regular expression would match "32" in the string...
3
3221
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is that this will one or more occurrences to replace all the white space between with a comma. This search ElseIf InStr(1, indivline, "$") Then insert a replace statement that uses the regular expression to find and replace all the white space...
7
3830
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I want to avoid that. My question here is if there is a way to pass either a memory stream or array of "find", "replace" expressions or any other way to avoid multiple copies of a string. Any help will be highly appreciated
9
3359
by: Pete Davis | last post by:
I'm using regular expressions to extract some data and some links from some web pages. I download the page and then I want to get a list of certain links. For building regular expressions, I use an app call The Regulator, which makes it pretty easy to build and test regular expressions. As a warning, I'm real weak with regular expressions. Let's say my regular expression is:
3
2566
by: Zach | last post by:
Hello, Please forgive if this is not the most appropriate newsgroup for this question. Unfortunately I didn't find a newsgroup specific to regular expressions. I have the following regular expression. ^(.+?) uses (?!a spoon)\.$
25
5169
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART (CONDUCTION DEFECT) 37.33/2 HEART (CONDUCTION DEFECT) WITH CATHETER 37.34/2 " the expression is "HEART (CONDUCTION DEFECT)". How do I gain access to the expression (not the matches) at runtime? Thanks, Mike
3
1841
by: Mr.Steskal | last post by:
Posted: Wed Jul 11, 2007 7:01 am Post subject: Regular Expression Help -------------------------------------------------------------------------------- I need help writing a regular expression that only returns part of a string. For Example I have a multi-line text fragment like below:
18
622
by: Lit | last post by:
Hi, I am looking for a Regular expression for a password for my RegExp ValidationControl Requirements are, At least 8 characters long. At least one digit At least one upper case character
0
9483
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10346
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.