<?php
$q = "
Boa __tarde__ **Bacco**, isto é um **teste** com diversos **negritos** e __sublinhados__
__**um** dois__
**__um__ dois**
" ;
$q = preg_replace ( '#(^|[^\*])\*\*([^\s\*]([^\*]+?)?[^\s\*])\*\*([^\*]|$)#' , '$1<b>$2</b>$4' , $q ) ; $q = preg_replace ( '#(^|[^_])__([^\s_]([^_]+?)?[^\s_])__([^_]|$)#' , '$1<u>$2</u>$4' , $q ) ;
PD9waHAKJHEgPSAiCkJvYSBfX3RhcmRlX18gKipCYWNjbyoqLCBpc3RvIMOpIHVtICoqdGVzdGUqKiBjb20gZGl2ZXJzb3MgKipuZWdyaXRvcyoqIGUgX19zdWJsaW5oYWRvc19fCgpfXyoqdW0qKiBkb2lzX18KKipfX3VtX18gZG9pcyoqCiI7CgokcSA9IHByZWdfcmVwbGFjZSgnIyhefFteXCpdKVwqXCooW15cc1wqXShbXlwqXSs/KT9bXlxzXCpdKVwqXCooW15cKl18JCkjJywgJyQxPGI+JDI8L2I+JDQnLCAkcSk7CiRxID0gcHJlZ19yZXBsYWNlKCcjKF58W15fXSlfXyhbXlxzX10oW15fXSs/KT9bXlxzX10pX18oW15fXXwkKSMnLCAnJDE8dT4kMjwvdT4kNCcsICRxKTsKCnZhcl9kdW1wKCRxKTsK