Matching a string to replace tag attributes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mattcooper
Forum Contributor
Posts: 210
Joined: Thu Mar 17, 2005 5:51 am
Location: London, UK

Matching a string to replace tag attributes

Post by mattcooper »

Hello again :)

I'm totally stumped by regex... I'm having trouble solving this and hope to learn some basics from whatever the outcome of this thread is.

Could someone tell me how to use regex to find a string such as this:

Code: Select all

colspan="2"
(where the number is, obviously, variable) so that I can replace it with a width attribute instead (I'm converting tables to divs)

All help gratefully received, as would be a link to a great regex tutorial (apart form the php manual, which I find too confusing for this!)

Cheers!
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

colspan="\d+"
Post Reply