5

sed replace bbcodes with regex

view full story
linux-howto

http://stackoverflow.com – I want to replace specific BBCodes like [youtube]http://youtube.com/watch?v=00000000000[\youtube] [youtube]http://youtu.be/00000000000[\youtube] [youtube]http://youtu.be/00000000000/[\youtube] [youtube]http://youtube.com/watch?v=00000000000&something=wrong[\youtube] [youtube]youtube.com/watch?v=00000000000[\youtube] to [MEDIA=youtube]00000000000[\MEDIA] My current pattern get no matches: sed -i 's/\[youtube\]\(http:\/\/|https:\/\/|.*\)\(www\.|.*\)youtu\(be\.com|\.be\)\(\/watch\?v=|\/\)\([a-zA-Z0-9-]{11}\)\(.*\)\[\/youtube\]/\[MEDIA=youtube\]\5\[\/MEDIA\]/g' text.txt What do you (HowTos)