javascript - What would be php equivalent of this code? -
var oktags = /^(<\/?(b|blockquote|code|del|dd|dl|dt|em|h1|h2|h3|i|kbd|li|ol|p|pre|s|sup|sub|strong|strike|ul)>|<(br|hr)\s?\/?>)$/i; var oklinks = /^(<a\shref="(\#\d+|(https?|ftp):\/\/[-a-za-z0-9+&@#\/%?=~_|!:,.;\(\)]+)"(\stitle="[^"<>]+")?\s?>|<\/a>)$/i; var okimg = /^(<img\ssrc="https?:(\/\/[-a-za-z0-9+&@#\/%?=~_|!:,.;\(\)]+)"(\swidth="\d{1,3}")?(\sheight="\d{1,3}")?(\salt="[^"<>]*")?(\stitle="[^"<>]*")?\s?\/?>)$/i; text = text.replace(/<[^<>]*>?/gi, function (tag) { return (tag.match(oktags) || tag.match(oklinks) || tag.match(okimg)) ? tag : "" })
replace()
can replaced preg_replace()
and match()
preg_match() powerful
check manual see how work code, not different, , can use call function too.
Comments
Post a Comment