开发者

Wiki syntax parser in Java

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开发者_StackOverflow中文版 Java.
converted = converted.replaceAll('/\'\'\'([^\n\']+)\'\'\'/',
    '<strong>${1}</strong>', converted);

Any one got any good suggestions for that? Thanks!


converted = converted.replaceAll("'{5}([^\n']+)'{5}", "<strong><i>$1</i></strong>");
  • I used '{5} instead of ''''' but they are the same.
  • The two delimiters / in PHP are specific to PHP. They should not appear in Java's regex.

BTW, you may use an existing MediaWiki parser instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜