devxlogo

String Manipulation

How to Write Underlined Text

Interestingly, underline is not a supported font style, i.e., you cannotsay Font.UNDERLINE to draw an underlined text. The trick is to use Graphics.drawLine() method to draw a line just below

Replace the last occurrence of a string

Here is a one-liner that replaces the last occurrence of a substring in a string. It is slightly less efficient than using the InstrRev plus a Replace statement, but at