TextFormatter/src/main/java/com/curios/textformatter/FormatText.java
public static CharSequence bold(CharSequence text) {

        try{
            Pattern pattern = Pattern.compile("\\*(.*?)\\*");
            SpannableStringBuilder ssb = new SpannableStringBuilder( text );

            if( pattern != null )
            {
                Matcher matcher = pattern.matcher( text );
                int matchesSoFar = 0;
                while( matcher.find() )
                {
                    int start = matcher.start() - (matchesSoFar * 2);
                    int end = matcher.end() - (matchesSoFar * 2);
                    CharacterStyle span = new StyleSpan(android.graphics.Typeface.BOLD);
                    ssb.setSpan( span, start + 1, end - 1, 0 );
                    ssb.delete(start, start + 1);
                    ssb.delete(end - 2, end -1);
                    matchesSoFar++;
                }
            }
            return ssb;
        }
        catch (Exception e){
            e.printStackTrace();
            return text;
        }
    }
/**
     * Any text enclosed between *s i.e *text* will be bolded
     * @param  text
     * @returns bolded and formatted text as a charsequence
     */
Any text enclosed between *s i.e *text* will be bolded
@param  text
@returns bolded and formatted text as a charsequence
Any text enclosed between * s i . e * text * will be bolded @param text @returns bolded and formatted text as a charsequence
public static CharSequence bold(CharSequence text) {
        try{
            Pattern pattern = Pattern.compile("\\*(.*?)\\*");
            SpannableStringBuilder ssb = new SpannableStringBuilder( text );
            if( pattern != null )
            {
                Matcher matcher = pattern.matcher( text );
                int matchesSoFar = 0;
                while( matcher.find() )
                {
                    int start = matcher.start() - (matchesSoFar * 2);
                    int end = matcher.end() - (matchesSoFar * 2);
                    CharacterStyle span = new StyleSpan(android.graphics.Typeface.BOLD);
                    ssb.setSpan( span, start + 1, end - 1, 0 );
                    ssb.delete(start, start + 1);
                    ssb.delete(end - 2, end -1);
                    matchesSoFar++;
                }
            }
            return ssb;
        }
        catch (Exception e){
            e.printStackTrace();
            return text;
        }
    }
public static CharSequence bold ( CharSequence text ) { try { Pattern pattern = Pattern . compile ( "\\*(.*?)\\*" ) ; SpannableStringBuilder ssb = new SpannableStringBuilder ( text ) ; if ( pattern != null ) { Matcher matcher = pattern . matcher ( text ) ; int matchesSoFar = 0 ; while ( matcher . find ( ) ) { int start = matcher . start ( ) - ( matchesSoFar * 2 ) ; int end = matcher . end ( ) - ( matchesSoFar * 2 ) ; CharacterStyle span = new StyleSpan ( android . graphics . Typeface . BOLD ) ; ssb . setSpan ( span , start + 1 , end - 1 , 0 ) ; ssb . delete ( start , start + 1 ) ; ssb . delete ( end - 2 , end - 1 ) ; matchesSoFar ++ ; } } return ssb ; } catch ( Exception e ) { e . printStackTrace ( ) ; return text ; } }
Any text enclosed between *s i.e *text* will be bolded
 @param  text
 @returns bolded and formatted text as a charsequence
Any text enclosed between * s i . e * text * will be bolded @param text @returns bolded and formatted text as a charsequence