Reputation: 541
I would like to make a wiki syntax parser in Java. I have one in PHP that goes a little something like this:
private static function runAllConversions($pString) {
$tConverted = $pString;
$tConverted = stripTags($tConverted);
// Bold and italic text.
$tConverted = preg_replace('/\'\'\'\'\'([^\n\']+)\'\'\'\'\'/',
'<strong><i>${1}</i></strong>', $tConverted);
In replacement I was thinking of replaceAll instead of the preg_replace in PHP. I guess it would be something like:
// Bold text in Java.
converted = converted.replaceAll('/\'\'\'([^\n\']+)\'\'\'/',
'<strong>${1}</strong>', converted);
Any one got any good suggestions for that? Thanks!
Upvotes: 0
Views: 687
Reputation: 523424
converted = converted.replaceAll("'{5}([^\n']+)'{5}", "<strong><i>$1</i></strong>");
'{5}
instead of '''''
but they are the same./
in PHP are specific to PHP. They should not appear in Java's regex.BTW, you may use an existing MediaWiki parser instead.
Upvotes: 2