RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 5
Title Test Details HTML Tag Remover
Expression
<\/?(tag1|tag2)[^>]*\/?>
Description
This is expression is good if you need to clean up some code (like from using DW Design View or Front Page). Just the "tag1" and "tag2" with the tags you want, and you can add more by putting a | inbetween each tag.
Matches
&lt;tag1 name="input" id="input"&gt; | &lt;tag2&gt; | &lt;tag1 src="/home.jpg" /&gt; | &lt;/tag1&gt;
Non-Matches
&lt;tag1 | tag2&gt;
Author Rating: Not yet rated. Kerry Jones
Title Test Details HTML Tag and InnerHTML Remover
Expression
<(tag1|tag2)[^>]*\/?>.*<\/(?:\1)>
Description
Removes all the text between two tags. Replace the "tag1" and "tag2" with the tag you want to remove, you can add more by placing additional "|" between each tag.
Matches
&lt;tag1&gt;Welcome!&lt;/tag1&gt; | &lt;tag1&gt;How &lt;b&gt;are&lt;/b&gt; you?&lt;/tag1&gt;
Non-Matches
&lt;tag1&gt;How &lt;b&gt;are&lt;/b&gt; you? | &lt;tag1&gt;How &lt;b&gt;are&lt;/b&gt; you?&lt;/tag2&gt;
Author Rating: Not yet rated. Kerry Jones
Title Test Details Find Relative Paths
Expression
(src|href|action)="(?!http://|#|mailto:|&)([^/#"])
Description
If when making a website you need to find your relative paths, this regex will find them. You can use the follow to make them absolute: \1="/\2
Matches
src="images" | href="index.html" | action="process.php"
Non-Matches
src="/images" | href="/index.html" | action="/process.php" | href="http://www.google.com" | href="mailto:ceo@ceo.com" | href="#" | href="" | href="&name=test"
Author Rating: The rating for this expression. Kerry Jones
Title Test Details Tag InnerHTML Remover
Expression
(<(tag1|tag2)[^>]*\/?>)[\w\S\s]*?(<\/(?:\2)>)
Description
This will remove the InnerHTML of a tag. For instance, if you wanted to clear all paragraphs and h1 tags on a page, you would simply put in "p" and "h1" into those tags, and they would end up looking like <h1></h1> <p></p> <p></p>. It's useful when you're doing work based off a template and you need to get back to the original template.
Matches
<tag1>Lorem ipsum dolor sit amet</tag1>
Non-Matches
<tag1>Lorem ipsum doler</othertag>
Author Rating: Not yet rated. Kerry Jones
Title Test Details Title Anchor Tags
Expression
<a((?:(?! title=)[^">]*"[^">]*")+)>([^<]+)<\/a>
Description
Use the above pattern with this replacement pattern: "<a\1 title="\2">\2</a>" and it will put title tags in all of your anchors that don't have a title tag.
Matches
&lt;a href="/"&gt;Home&lt;/a&gt; | &lt;a href="/" style="font-size: 30px"&gt;Home&lt;/a&gt;
Non-Matches
&lt;a href="/"&gt;&lt;span style="font-size: 30px"&gt;Home&lt;/span&gt;&lt;/a&gt;
Author Rating: Not yet rated. Kerry Jones
   Displaying page 1 of 1 pages; Items 1 to 5

Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials