Andrew Ohnstad wrote:
> I suppose so, but then that will leave messy broken images on my pages
> and clog up my logs with requests for invalid graphics.
> 
> I'm wrangling a regex, but I can figure out how to negate a string.
> What I want is something like this:
> 
> STARTS WITH "<img " AND THEN IS NOT "src=/" AND THEN IS "* >"  That
> will trap the contents of <img src=http...> or <img src="http...> etc.
> all in one reference for deletion with gsub.
> 
> /<img [^src=\/]*>/  obviously doesn't work because it's matching 's'
> OR 'r' OR 'c'...  I tried enclosing "src=\/" in quotes, single quotes,
> back quotes, curly braces, etc. but can't figure this out.
> 
> I suck at regex and google isn't helping this time.
> 
> 
> On Apr 4, 11:47�am, Frederick Cheung <[email protected]>

Might try something like:

string=<<EOF
  <img src=/...>
  <img src="/...>
  <img src=http://...>
EOF

img_reg = Regexp.new('<img src=[^"/].*>')
img_reg.match(string)
puts match.to_s


This is more of a blacklist solution however. Hope it helps get you on 
the right track.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to