Regular Expression to change output width

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Regular Expression to change output width

Postby Pirate Elf » Tue Dec 15, 2009 12:59 am

Guys, I'm rusty at best, but here recently I have been getting back into working on small projects. My recent project is a friend wants to make it to where whenever anyone posts an embedded file (say like youtube) it will search for the width and no matter what the width is it will replace it with width="500". I never fully wrapped my head around regex so this one is stumping me. I get what I want to do, and a general concept of what the code may look like, but wondering if anyone else could look over it and give me some pointers.

Intial Code Concept
Code: Select all
sub ImageSize {
my $text = shift;
if ($text =~ m/(width=.*?\")/i) {
$width =~ s/(width=.*?\")/width=\"500\"/ig;
return $text}
Nichts ist für dich
Nichts war für dich
Nichts bleibt für dich
Für immer
=-=-=-=-=-=-=-=-=-=-=-=-=
User avatar
Pirate Elf
 
Posts: 783
Joined: Wed Jan 31, 2007 9:45 pm
Location: Inside of Coranto lookings for bugs, and sometimes making them!

Re: Regular Expression to change output width

Postby SrNupsen » Tue Jan 05, 2010 7:58 pm

Um... was ist falsch mit dem Search & replace addon?
-----------------------------------------------------
http://www.sundaune.no - Sundaune tekst, reklame, tekst, manus, korrektur, transkripsjon, oversettelser, webdesign, publiseringsløsninger
-----------------------------------------------------
SrNupsen
 
Posts: 2266
Joined: Tue Jan 09, 2007 6:46 pm
Location: Nesodden, outside Oslo, Norway


Return to Customization

Who is online

Users browsing this forum: No registered users and 1 guest