in user text i have some star into that and i'm trying to convert them to html
regular tags, for example, user text is :
For every loop iteration, the ** value ** of the current ** array element ** is assigned to $value and ** the array pointer ** is moved by one, until it reaches the last array element.
as you see i have some words between stars such as value
, array element
and etc, now i want to convert first star to <b>
and second star to </b>
, then finally i should have:
For every loop iteration, the <b> value </b> of the current <b> array
element </b> is assigned to $value and <b> the array pointer
<b> is moved by one, until it reaches the last array element.
this below code which i implemented on php
work fine and i'm trying to find equivalent that on java
$re = '/\*\*(.*?)\*\*/';
$str = 'For every loop iteration, the ** value ** of the current ** array element ** is assigned to $value and ** the array pointer ** is moved by one, until it reaches the last array element.';
$subst = '<b>$1</b>';
$result = preg_replace($re, $subst, $str);
echo $result;