Try with this pattern :
/<table ([^>]*?)width=["']s?d+s?(px|%)?s*["']/
The replacement $1
would preserve any other attributes (cf. (.*?)
capture group) :
$text = preg_replace('/<table (.*?)width=["']s?d+s?(px|%)?s*["']/', '<table $1width="100%"', $text);