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

Please support RegExLib Sponsors

Sponsors

Advanced Search

Keywords

Category

Minimum Rating

Results per Page

Search Results: 18 regular expressions found.

   Displaying page 1 of 1 pages; Items 1 to 18
Title Test Details Pattern Title
Expression
<img([^>]*[^/])>
Description
Use this along with this replacement string &lt;img\1 /&gt; to convert image tags to XHTML compliant image tags.
Matches
<img src="bob">
Non-Matches
<img src="bob" />
Author Rating: The rating for this expression. Murray Roke
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(&quot;/(\[IMG\])(\S+?)(\[\/IMG\])/is&quot;, &quot;&lt;a href=\&quot;\\2\&quot; target=\&quot;_blank\&quot;&gt;&lt;IMG SRC=\&quot;\\2\&quot; align=\&quot;center\&quot; height=\&quot;100\&quot; border=\&quot;0\&quot;&gt;&lt;/a&gt;&quot;,$text); so whenever they use [img]http://www.foo.com/bleh.jpg[/img] it will be converted to &lt;a href=&quot;http://www.foo.com/bleh.jpg&quot; target=&quot;_blank&quot;&gt;&lt;IMG SRC=&quot;http://www.foo.com/bleh.jpg&quot; align=&quot;center&quot; height=&quot;100&quot; border=&quot;0&quot;&gt;&lt;/a&gt; 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
&lt;img src=&quot;bleh.jpg&quot;&gt;
Author Rating: The rating for this expression. marnik vander elst
Title Test Details Pattern Title
Expression
&lt;[iI][mM][gG]([^&gt;]*[^/&gt;])
Description
simple little RegExp to get the IMG tag from HTML
Matches
&lt;img src=&quot;abc.jpg&quot;&gt; | &lt;img src=&quot;abc.jpg&quot;/&gt; | &lt;ImG src=&quot;abc.j
Non-Matches
none
Author Rating: Not yet rated. Asim Goheer
Title Test Details Pattern Title
Expression
<[a-zA-Z]+(\s+[a-zA-Z]+\s*=\s*("([^"]*)"|'([^']*)'))*\s*/>
Description
Matches a valid &quot;empty&quot; tag (has trailing slash). Note, if you run it against a string such as &lt;img src=&quot;test.gif&quot; alt=&quot;&lt;hr /&gt;&quot;&gt; 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 &lt;hr /&gt;. 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... &lt;img src=&quot;truc&quot;&gt; returns : &lt; (1:img) (2: src=&quot;truc&quot;) &gt; i use it to clean html pages to grab infos... use a RegEx Replace with &quot;&lt;$1&gt;&quot; 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[^&gt;]*[^/].(?:jpg|bmp|gif)(?:\&quot;|\')
Description
This expression will return the src (source) property of an image tag &lt;IMG&gt;. 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 &lt;BGSOUND&gt;, &lt;SCRIPT&gt;, 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 &lt;IMG&gt; tag, I would appreciate the effort.
Matches
src=&quot;../images/image.jpg&quot; | src=&quot;http://domain.com/images/image.jpg&quot; | src='d:\w
Non-Matches
src=&quot;../images/image.tif&quot; | src=&quot;cid:value&quot;
Author Rating: The rating for this expression. Lloyd Sturge
Title Test Details Pattern Title
Expression
&lt;img .+ src[ ]*=[ ]*\&quot;(.+)\&quot;
Description
Gets the image url in an HTML &lt;IMG&gt; tag.
Matches
&lt;img src=&quot;test.jpg&quot;&gt; | &lt;img align = &quot;left&quot; src = &quot;test.jpg&quot;&g
Non-Matches
unknown
Author Rating: Not yet rated. Judah Himango
Title Test Details img
Expression
<img[^>]* src=\"([^\"]*)\"[^>]*>
Description
It searches for a IMG tag and group information about source of image.
Matches
<img src="joka.jpg" /> <img src="joka.jpg">
Non-Matches
<img> <img src=dada>
Author Rating: Not yet rated. Jan Filipowski
Title Test Details replace html tags with valid xhtml
Expression
(<input )(.*?)(>)
Description
Finds all &lt;input attrib1="value1" attrib2="value2" ... &gt; tags. You can make it end with "/&gt;" for xhtml compatibility replacing with the expression "&lt;input $2 /&gt;". You can repeat it with other tags like &lt;img /&gt; or &lt;br / &gt;
Matches
&lt;input attrib1="value1" attrib2="value2" &gt;
Non-Matches
any other tag
Author Rating: Not yet rated. Mauricio Venanzoni
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: The rating for this expression. 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 Match Valid HTML Tags As Browser
Expression
<(/)?(a|abbr|acronym|address|applet|area|b|base|basefont|bdo|big|blockquote|body|br|button|caption|center|cite|code|col|colgroup|dd|del|dir|div|dfn|dl|dt|em|fieldset|font|form|frame|frameset|h[1-6]|head|hr|html|i|iframe|img|input|ins|isindex|kbd|label|legend|li|link|map|menu|meta|noframes|noscript|object|ol|optgroup|option|p|param|pre|q|s|samp|script|select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt|u|ul|var|xmp){1}(\s(\"[^\"]*\"*|[^>])*)*>
Description
This should match all valid HTML 4.01 tags as a browser would recognize. If you miss a 2nd " it will continue until it finds one to pair with, so if it doesn't find one, it continues until the end. This is how most browsers work I believe. It does have a few flaws, it will match </img> and </input> which is weird, but perhaps I'll fix that eventually.
Matches
</a> <h2 > </h2 asfsdf> <a href="abc>>123">
Non-Matches
< /a> </h 2 asfsdf> <ahref="abc123">
Author Rating: The rating for this expression. John Smith
Title Test Details Floating Complex Number Accessible
Expression
^((?<r>([-+]?(\d+\.?\d*|\d*\.?\d+)([Ee][-+]?[0-2]?\d{1,2})?[r]?))|(?<i>([-+]?((\d+\.?\d*|\d*\.?\d+)([Ee][-+]?[0-2]?\d{1,2})?)?[i]))|(?<r>([-+]?(\d+\.?\d*|\d*\.?\d+)([Ee][-+]?[0-2]?\d{1,2})?[r]?))(?<i>([-+]((\d+\.?\d*|\d*\.?\d+)([Ee][-+]?[0-2]?\d{1,2})?)?[i])))$
Description
This is the same regex pattern as 'Floating Complex Number' but extented by group names. This makes it much easier to extract the parts of the complex number (e.g. string realPart=myMatch.Result("${r}");string imgPart=myMatch.Result("${i}"); ).
Matches
see base example
Non-Matches
see base example
Author Rating: Not yet rated. Fischer, M.
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
&lt;img src="xxx"&gt; | &lt;img src=xxx&gt; | &lt;img src="xxx" alt="xxx" /&gt; | &lt;img src="xxx" alt="xxx" width="N" height="N" /&gt; | etc.
Non-Matches
&lt;img&gt; | &lt;img /&gt; | &lt;img alt="XXX" src="XXX"&gt;
Author Rating: The rating for this expression. 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 Strip HTML tags with exceptions
Expression
<\/*?(?![^>]*?\b(?:a|img)\b)[^>]*?>
Description
This regex will match all HTML tags except 'a' tags or 'img' tags. You can edit the list of exclusions as you see fit. I use this regex to strip all HTML tags from source data except anchor tags and image tags.
Matches
<script> </html> <anytag>
Non-Matches
<a> <img /> </a>
Author Rating: The rating for this expression. Charles Forsyth
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: The rating for this expression. Ricardo Deus
Title Test Details Valid YouTube links
Expression
(http://)?(www\.)?(youtube|yimg|youtu)\.([A-Za-z]{2,4}|[A-Za-z]{2}\.[A-Za-z]{2})/(watch\?v=)?[A-Za-z0-9\-_]{6,12}(&[A-Za-z0-9\-_]{1,}=[A-Za-z0-9\-_]{1,})*
Description
Matches only valid YouTube links. This includes directly linked videos (yimg) and using YouTube's shortening service (youtu.be). Also supports local domains, like youtube.nl, youtube.de, youtube.co.uk, etc.
Matches
www.youtube.co.uk/watch?v=KUlv7qraZaM | http://www.yimg.com/watch?v=KUlv7qraZaM | http://www.youtube.com/watch?v=apxKFXJ8jSg&feature=relmfu | youtu.be/apxKFXJ8jSg
Non-Matches
youtube.com/watch/v=apxKFXJ8jSg
Author Rating: Not yet rated. Pim Stoit
   Displaying page 1 of 1 pages; Items 1 to 18

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