We can use sling transformers to rewrite V John to V-John, because we don't know in which component this text comes, it is difficult to go and modify every component and also when it comes to maintenance it is tough.
With this TransformerFactory you can rewrite URLs, modify HTML elements content, add attributes to HTML elements, etc. you can refer below the sample code, it is reading image src attribute and changing it is CDN based URL.
public void startElement(String uri, String loc, String raw, Attributes attributes) throws SAXException {
AttributesImpl attrs = new AttributesImpl(attributes);
for (int i = 0; i < attrs.getLength(); i++) {
String name = attrs.getLocalName(i);
if(name.equals("src"))
{
String url = attrs.getValue(i);
url = "http://cdn.coderss.in" + url;
attrs.setValue(i, url);
}
}
super.startElement(uri, loc, raw, attrs);
}
in your case, you need to read the text of the paragraph inside the startElement method and look for V John and change it to V-John wherever you find.
For more information, you can refer to this
http://www.coderss.in/apache-sling-rewriter-how-to-rewrite-urls-in-aemcq5/
https://www.cognifide.com/our-blogs/zen-garden/aem-transformers
You can also configure this to run only certain elements and only for specific paths.
<custom-pipeline
jcr:primaryType="nt:unstructured"
contentTypes="text/html"
generatorType="htmlparser"
order="1"
paths="[/content/aemtookit]"
serializerType="htmlwriter"
transformerTypes="[linkchecker,preserve-wcmmode-transformer]">
<generator-htmlparser
jcr:primaryType="nt:unstructured"
includeTags="[A,/A,IMG,AREA,FORM,BASE,LINK,SCRIPT,BODY,/BODY,DIV,/DIV]" />
</custom-pipeline>