Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expressions

Status
Not open for further replies.

IndyFusion

Programmer
Jan 9, 2003
7
0
0
US
I have the following HTML:
Code:
<P>test</P>
<P>test</P><DFN>
<P>test</P></DFN>
I am using the code:

var re = &quot;<dfn>(?:.+)<\/dfn>&quot;;
var oReg = new RegExp(re,&quot;igm&quot;);
var result = content.replace(oReg, '');

result always comes back with null.

I am trying to remove the DFN and everything in between and it is not working. I am assuming it is because the HTML is on 3 seperate lines. I cannot control the HTML so it must stay on 3 lines. I need a way to get rid of the DFN tag and everything in between it.

I've tried using &quot;<dfn>(?:[\s\S]+)<\/dfn>&quot;, but I get the same thing. What am I doing wrong? I've spend close to three hours working on this simple problem and can't figure it out. Can anyone PLEASE help?!
 
are you trying to affect the actual source code? where are you defining &quot;content&quot;?

=========================================================
if (!succeed) try();
-jeff
 
Jeff,

The HTML at the top of the thread is in the variable content. Yes, I am trying to remove the source code DFN and everything in between. Sorry I didn't specify this before.

Thanks,
Jason
 
this seems to work for me:

var re = &quot;<dfn>.*\n?.*<\/dfn>&quot;;
var oReg = new RegExp(re,&quot;igm&quot;);

=========================================================
if (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top