List Info

Thread: Seeking Regex Help




Seeking Regex Help
country flaguser name
United States
2007-02-21 14:20:53
Greetings,

I am trying to create a regex to extract the contents of a
multi-line
DIV tag.

Sample HTML code:
----------------------------------------------------------
<html>
<body>

Some text here. Blah, blah, blah...

<div class="editable"
test="4"><p><strong>This is the
title.</strong>
for this page.</p>
<p />
<p>Here is some more text</p></div>

Some text here. Blah, blah, blah...

</body>
</html>
---------------------------------------------------------



I would like to extract the text from the <div> tag
that has the class
set to editable to return the following:
--------------------------------------------------------
<p><strong>This is the title.</strong> for
this page.</p>
<p />
<p>Here is some more text</p>
--------------------------------------------------------


I can target the <div> using:
-------------------------------------------------------
<div(?:.*?)classs*=s*""*editable""*
.*?>(.*)</div>
-------------------------------------------------------
but it only returns the first line from inside the div. It
won't look
past newlines and/or returns.


I am using VBScript on a windows machine. Any help would be
GREATLY
appreciated!

Regards,
Drn


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Seeking Regex Help
user name
2007-02-21 23:35:10
Hi adelphia.net" style="color: rgb(0, 104, 28);">dspaffordadelphia.net" style="color: rgb(0, 104, 28);">adelphia.net
My self Sanket
Instead of creating regex u can go for javascript
var str = document.getElementById("divId").innerHtml
will get all innerHtml of div with id "divId" to variable str


On 2/22/07, Drn < dspaffordadelphia.net">dspaffordadelphia.net> wrote:

Greetings,

I am trying to create a regex to extract the contents of a multi-line
DIV tag.

Sample HTML code:
----------------------------------------------------------
<html>;
<body&gt;

Some text here. Blah, blah, blah...

&lt;div class=&quot;editable&quot; test=";4">;<p>&lt;strong&gt;This is the title.</strong>
for this page.</p>
<p />
<p>Here is some more text</p></div>

Some text here. Blah, blah, blah...

&lt;/body>;
</html>
---------------------------------------------------------



I would like to extract the text from the <div>; tag that has the class
set to editable to return the following:
--------------------------------------------------------
<p>;<strong>This is the title.</strong> for this page.</p>
<p />
<p>Here is some more text</p>
--------------------------------------------------------


I can target the <div>; using:
-------------------------------------------------------
&lt;div(?:.*?)classs*=s*"";*editable&quot;"*.*?>(.*)</div&gt;
-------------------------------------------------------
but it only returns the first line from inside the div. It won't look
past newlines and/or returns.


I am using VBScript on a windows machine. Any help would be GREATLY
appreciated!

Regards,
Drn



&nbsp; `·.¸(¨`·.·´¨) Keep
(¨`·.·´¨)¸.·´ Smiling!
&nbsp; `·.¸.·´

Sanket Pathre
Junier Trainee engineer
Akstech Pvt, Ltd.(Vashi)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/regex
-~----------~----~----~----~------~----~------~--~---

Re: Seeking Regex Help
country flaguser name
United States
2007-02-22 08:08:53
Thanks Sanket!

I tried that too. Some additional challenges:

> There may be more than one of these <div> tags on
a page at a time.
> The <div> tags I am seeking may have other
<div> tags in them.
> I need to do a replace on the code.

In essence, the string I am executing the replace on is HTML
code for
an entire page. Ideally, I would like to globally find any
of these
<div> tags, pluck out the contents, and replace the
<div> itself with
javascript code that uses the contents somehow.

My apologies for not putting this information in before. I
am sort of
figuring it out as I go.



On Feb 22, 12:35 am, "Sanket Pathre"
<sanketpat...gmail.com> wrote:
> Hi dspaff...adelphia.net
> My self Sanket
> Instead of creating regex u can go for javascript
> var str =
document.getElementById("divId").innerHtml
> will get all innerHtml of div with id "divId"
to variable str
>
> On 2/22/07, Drn <dspaff...adelphia.net> wrote:
>
>
>
>
>
>
>
> > Greetings,
>
> > I am trying to create a regex to extract the
contents of a multi-line
> > DIV tag.
>
> > Sample HTML code:
> >
----------------------------------------------------------
> > <html>
> > <body>
>
> > Some text here. Blah, blah, blah...
>
> > <div class="editable"
test="4"><p><strong>This is the
title.</strong>
> > for this page.</p>
> > <p />
> > <p>Here is some more
text</p></div>
>
> > Some text here. Blah, blah, blah...
>
> > </body>
> > </html>
> >
---------------------------------------------------------
>
> > I would like to extract the text from the
<div> tag that has the class
> > set to editable to return the following:
> >
--------------------------------------------------------
> > <p><strong>This is the
title.</strong> for this page.</p>
> > <p />
> > <p>Here is some more text</p>
> >
--------------------------------------------------------
>
> > I can target the <div> using:
> >
-------------------------------------------------------
> >
<div(?:.*?)classs*=s*""*editable""*
.*?>(.*)</div>
> >
-------------------------------------------------------
> > but it only returns the first line from inside the
div. It won't look
> > past newlines and/or returns.
>
> > I am using VBScript on a windows machine. Any help
would be GREATLY
> > appreciated!
>
> > Regards,
> > Drn
>
> --
>
> (¨`·.·´¨) Always
>   `·.¸(¨`·.·´¨) Keep
> (¨`·.·´¨)¸.·´ Smiling!
>   `·.¸.·´
>
> Sanket Pathre
> Junier Trainee engineer
> Akstech Pvt, Ltd.(Vashi)- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Seeking Regex Help
country flaguser name
United States
2007-02-22 11:50:59
On Feb 22, 4:20 am, "Drn" <dspaff...adelphia.net> wrote:
> Greetings,
>
> I am trying to create a regex to extract the contents
of a multi-line
> DIV tag.
>
> Sample HTML code:
>
----------------------------------------------------------
> <html>
> <body>
>
> Some text here. Blah, blah, blah...
>
> <div class="editable"
test="4"><p><strong>This is the
title.</strong>
> for this page.</p>
> <p />
> <p>Here is some more text</p></div>
>
> Some text here. Blah, blah, blah...
>
> </body>
> </html>
>
---------------------------------------------------------
>
> I would like to extract the text from the <div>
tag that has the class
> set to editable to return the following:
>
--------------------------------------------------------
> <p><strong>This is the
title.</strong> for this page.</p>
> <p />
> <p>Here is some more text</p>
>
--------------------------------------------------------
>
> I can target the <div> using:
>
-------------------------------------------------------
>
<div(?:.*?)classs*=s*""*editable""*
.*?>(.*)</div>

You can either change (.*)  to  ([sS]*?)
or prepend a (?s) to your pattern which means 'dot matches
newline',
but I dont know if VBScript supports that modifier..

BTW. you didnt mention if there are any multiple embedded
<div> tags
and how you want to handle them..

Regards,
Xicheng

>
-------------------------------------------------------
> but it only returns the first line from inside the div.
It won't look
> past newlines and/or returns.
>
> I am using VBScript on a windows machine. Any help
would be GREATLY
> appreciated!
>
> Regards,
> Drn


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )