Displaying page
of
pages;
Items to
Title |
Test
Details
Pattern Title
|
Expression |
(\[[Ii][Mm][Gg]\])(\S+?)(\[\/[Ii][Mm][Gg]\]) |
Description |
easy when you want to allow your users to post images, but in a controlled way. I used it like this (in php):
$text = preg_replace("/(\[IMG\])(\S+?)(\[\/IMG\])/is", "<a href=\"\\2\" target=\"_blank\"><IMG SRC=\"\\2\" align=\"center\" height=\"100\" border=\"0\"></a>",$text);
so whenever they use
[img]http://www.foo.com/bleh.jpg[/img]
it will be converted to
<a href="http://www.foo.com/bleh.jpg" target="_blank"><IMG SRC="http://www.foo.com/bleh.jpg" align="center" height="100" border="0"></a>
so you get a 100 pixels high picture, and when they click on it it opens in a new window...
(to prevent users from posting huge pictures and stuff) |
Matches |
[IMG]http://bleh.jpg[/IMG] | [ImG]bleh[/imG] | [img]ftp://login: [email protected][/img] |
Non-Matches |
<img src="bleh.jpg"> |
Author |
Rating:
marnik vander elst
|
Title |
Test
Details
Pattern Title
|
Expression |
<[a-zA-Z]+(\s+[a-zA-Z]+\s*=\s*("([^"]*)"|'([^']*)'))*\s*/> |
Description |
Matches a valid "empty" tag (has trailing slash). Note, if you run it against a string such as <img src="test.gif" alt="<hr />"> it will indeed return a match. But, the match is not at character 1 like you'd suspect, but rather it's matching the internal <hr />. If you look at the source of this tag (http://concepts.waetech.com/unclosed_tags/) you'll find a whoe suite of regex's for matching html tags. Using them you could feasibly step though a document and avoid this mismatch as the outer tag would match *in totality* and you'd completely skip this inner match.
|
Matches |
<img src="test.gif"/> |
Non-Matches |
<img src="test.gif"> | <img src="test.gif"a/> |
Author |
Rating:
Not yet rated.
Joshua Olson
|
Title |
Test
Details
Pattern Title
|
Expression |
<([^\s>]*)(\s[^<]*)> |
Description |
grab all tags attributes...
<img src="truc"> returns :
<
(1:img)
(2: src="truc")
>
i use it to clean html pages to grab infos...
use a RegEx Replace with "<$1>" to keep only tags codes... |
Matches |
<img src="truc"> | <body background='...'> | <p align='left'> |
Non-Matches |
<br> | </body> | <p> |
Author |
Rating:
Not yet rated.
Tanguy Pruvot
|
Title |
Test
Details
Pattern Title
|
Expression |
src[^>]*[^/].(?:jpg|bmp|gif)(?:\"|\') |
Description |
This expression will return the src (source) property of an image tag <IMG>. The source returned is limited to the file extensions supplied. It doesn't matter if the image is prefixed with '../' or 'http://..blah' or 'drive\path' or nothing. This expression could be modifed to return other sources or for the tags (ie <BGSOUND>, <SCRIPT>, etc.) depending on the file extensions given.
I needed this to replace the source of images in a HTML page when I wanted to save the page to a local drive and keep the images intact.
If anybody could modify this further to include only the <IMG> tag, I would appreciate the effort. |
Matches |
src="../images/image.jpg" | src="http://domain.com/images/image.jpg" | src='d:\w |
Non-Matches |
src="../images/image.tif" | src="cid:value" |
Author |
Rating:
Lloyd Sturge
|
Title |
Test
Details
Manage img
|
Expression |
<img[\s]+[^>]*?((alt*?[\s]?=[\s\"\']+(.*?)[\"\']+.*?)|(src*?[\s]?=[\s\"\']+(.*?)[\"\']+.*?))((src*?[\s]?=[\s\"\']+(.*?)[\"\']+.*?>)|(alt*?[\s]?=[\s\"\']+(.*?)[\"\']+.*?>)|>) |
Description |
This pattern can intercept img like < img src="src1" alt="alt1"> or < img alt="alt1" src="src1"> or < img src="src1"> or < img src="src1" width=3 height=4> then values of src can be found in $5 or $8, the value of tag alt can be found in $3 or $10. |
Matches |
< img src="src 1" alt="alt 1"> or < img src="src 2"> or < img src="src 3" alt="alt 3" width=2 height=3> |
Non-Matches |
any other tag |
Author |
Rating:
Cordisco Massimo
|
Title |
Test
Details
Img Src Attribute
|
Expression |
src=(?:\"|\')?(?<imgSrc>[^>]*[^/].(?:jpg|bmp|gif|png))(?:\"|\')? |
Description |
This pattern matches an image url attribute of an img html tag. It searches for the src attribute and grabs the value as a grouped match - "imgSrc". |
Matches |
src="http://www.thoughtlava.com/images/logo.gif" | src='http://www.thoughtlava.com/images/logo.gif' | src=http://www.thoughtlava.com/images/logo.gif |
Non-Matches |
src="http://www.thoughtlava.com/images/logo.wmf" |
Author |
Rating:
Not yet rated.
Steven Pena
|
Title |
Test
Details
Extract "src" attr from EMBED tag (for Flash)
|
Expression |
(?<=<embed\s[^<>]*?src\s*?=\s*?\x22)[^<>]*?(?=\x22[^<>]*?>) |
Description |
This pattern will extract the "src" attribute of an EMBED tag. I created it for extracting the URI of an Adobe Flash animation from some HTML, but of course it would work for more general purposes. Don't forget to turn on case insensitivity. |
Matches |
In <embed src="somefilename.swf" width="550" height="400"> matches "somefilename.swf" |
Non-Matches |
Doesn't match the surrounding HTML. |
Author |
Rating:
Not yet rated.
Tim Denby
|
Title |
Test
Details
Script Block Parser
|
Expression |
<script(?:(?:.*(?<src>(?<=src=")[^"]*(?="))[^>]*)|[^>]*)>(?<content>(?:(?:\n|.)(?!(?:\n|.)<script))*)</script> |
Description |
This one enables you to parse well-formed script tags to get both the src value and the block content, if specified. I'm using this one in some AJAX where I get script blocks back in a text reponse and need to parse them and add them to the DOM so they get processed. |
Matches |
<script type="text/javascript" src="Test.js"></script> |
Non-Matches |
<script src=Test.js></script> |
Author |
Rating:
Not yet rated.
Ambrose
|
Title |
Test
Details
Detect Javascript
|
Expression |
<script.*/*>|</script>|<[a-zA-Z][^>]*=['"]+javascript:\w+.*['"]+>|<\w+[^>]*\son\w+=.*[ /]*> |
Description |
Matches any opening or closing script tags, inline javascript: tags, inline on<function> (ex: onClick) tags.
MATCHES:
<a href="javascript:alert('test0');">
<a href='javascript:alert("test1");'>
<a href="#" onClick="alert('test2');" />
<script language="javascript" src="somewhere.js">
<script language="javascript" src="somewhere.js" />
<script>
</script> |
Matches |
<a href="javascript:alert('test0');"> or <a href="#" onClick="alert('test');" /> etc... |
Non-Matches |
This should not appear because in javascript: you can use the < operator or the > operator. |
Author |
Rating:
Not yet rated.
Denny Love
|
Title |
Test
Details
HTML Image src
|
Expression |
<[iI][mM][gG][a-zA-Z0-9\s=".]*((src)=\s*(?:"([^"]*)"|'[^']*'))[a-zA-Z0-9\s=".]*/*>(?:</[iI][mM][gG]>)* |
Description |
Great for extracting out all the image src attributes. |
Matches |
<img src="gif.gif" ></img>|<img id="blah" src="gif"></img>|<img src="gif.gif" id="freaky">|</img>|<img src="gif.gif" />|<img src="gif.gif"/>|<img class="FloatLeft Margin" id="calendarButton81" src="calendar.gif" alt="Calendar Button" /> |
Non-Matches |
<input id="" value=""/> |
Author |
Rating:
Erik
|
Title |
Test
Details
IMG tag
|
Expression |
<img[^>]*src=\"?([^\"]*)\"?([^>]*alt=\"?([^\"]*)\"?)?[^>]*> |
Description |
Use this RegExp to grab SRC($1) and ALT($3) values from IMG tags in valid or invalid HTML (XHTML). SRC param must by before IMG. (thanks to mr. Mrva) |
Matches |
<img src="xxx"> | <img src=xxx> | <img src="xxx" alt="xxx" /> | <img src="xxx" alt="xxx" width="N" height="N" /> | etc. |
Non-Matches |
<img> | <img /> | <img alt="XXX" src="XXX"> |
Author |
Rating:
Martin Švec
|
Title |
Test
Details
Capture HTML Tags
|
Expression |
<font[a-zA-Z0-9_\^\$\.\|\{\[\}\]\(\)\*\+\?\\~`!@#%&-=;:'",/\n\s]*> |
Description |
This expression will capture font tags(or any other HTML tag if you change the word font in the expression) with parameters and stop at the closing font tag bracket. The only keyboard characters it will not find between the starting and ending bracket are additional brackets. So for example if you are looking for image tags it will not find <img src="..." alt=">My Picture<"> due to the nested brackets. When I allowed nested brackets like this the expression did not always return only the tag I was looking for. Sometimes it returned additional tags at the end so I suggest staying away from brackets in alt text and anywhere else you may be allowed to do it. |
Matches |
<font color="#006666">, <font face="arial" style="font-size: 11pt"> |
Non-Matches |
<font, </font>, <font <> |
Author |
Rating:
Not yet rated.
Kurt McEllhenney
|
Title |
Test
Details
Parse linked url
|
Expression |
((?<html>(href|src)\s*=\s*")|(?<css>url\())(?<url>.*?)(?(html)"|\)) |
Description |
Given HTMl or CSS source, find the value of all href and src attributes + anything between url(). |
Matches |
href="foo"|scr="foo"|url(foo) |
Non-Matches |
href(foo)|src(foo)|url="foo" |
Author |
Rating:
Not yet rated.
Tinminator
|
Title |
Test
Details
Identify relative urls
|
Expression |
(src|href|action)\s*=\s*('|"|(?!"|'))(?!(http:|ftp:|mailto:|https:|#)) |
Description |
After hitting little snags through the years here is a [WIP] for replacing relative links. Notice that it considers whitespace between the src,href and the equal sign, it also considers the links may not have any quotes around them. It negates urls that start with http,ftp,link anchors, https and mailto. |
Matches |
href=" src = "pa href='../ |
Non-Matches |
href="mailto: href="mailto: src='ftp: |
Author |
Rating:
Not yet rated.
Esteban Smits
|
Title |
Test
Details
Parse HTML images
|
Expression |
"<[ \t]*[iI][mM][gG][ \t]*[sS][rR][cC][ \t]*=[ \t]*['\"]([^'\"]+)" |
Description |
Get all images in html string, ignore white space, tabs and is case insensitive. the result is iMG sRc ="ricardo.gif, after this just split the string and Enjoy it! |
Matches |
"<html><iMG sRc = \"ricardo.gif\" alt=\"1\"/><img src=\"whatever.gif\" /><img src =\"teste.gif\" alt=\"1\"/></html>" |
Non-Matches |
i don´t know |
Author |
Rating:
Ricardo Deus
|
Displaying page
of
pages;
Items to