...

View Full Version : RegEx help



gsnedders
02-16-2006, 06:15 PM
I've managed to get this:

echo preg_replace('/<(\S):(\S)(.*)>/msiU', '<\\2\\3>', '<blah:blah test="test: this">');

However, that doesn't remove anything. What it should output is:

<blah test="test: this">

fci
02-16-2006, 06:22 PM
echo preg_replace('/<(?:[a-zA-Z]+:)/m', '<', '<blah:blah test="test: this">');
remember to use htmlentities so your browser doesn't render while testing (or view the source).

gsnedders
02-16-2006, 06:28 PM
What does that "?:" do?

fci
02-16-2006, 06:31 PM
What does that "?:" do?

it means it is non capturing unlike just using normal parentheses(capturing) which will give you the \1 and so on.

gsnedders
02-16-2006, 06:32 PM
Ah, OK. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum