import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\s(([a-zA-Z]+\\-[a-zA-Z]+|[a-zA-Z]+)\\.)";
final String string = "<p>With consumers becoming more and more health-conscious by the minute, the wearable fitness tracker market is ever-expanding.</p>\n"
+ "<p>So, to cut through the clutter, we created a lifestyle video series and an interactive kiosk experience at Best Buy, where we were able to inform and educate consumers about Jawbone’s Up products right there at point of sale.</p>\n"
+ "<p>By arming consumers with the knowledge on how to improve their personal physical fitness, they’re able to make informed decisions with the push of a button. As part of the experience, visually stimulating films helped people easily understand each product’s features and benefits as well as identify which product best fit their needs.</p>\n"
+ "<p>The lifestyle and product demonstration films within the interactive experience were also used across social media, the Jawbone website, and as TV spots in two countries.</p>\n"
+ "<div class=\"image\"><a href=\"http://goldenarm.com/staging/wp-content/uploads/2015/06/UpKiosk.jpg\"><img class=\"aligncenter wp-image-1156 size-large\" src=\"http://goldenarm.com/staging/wp-content/uploads/2015/06/UpKiosk-1024x643.jpg\" alt=\"\" width=\"1024\" height=\"643\"></a><img class=\"aligncenter wp-image-1348 size-large\" src=\"http://goldenarm.com/staging/wp-content/uploads/2015/06/6.-youpush-1600px-1024x576ABC.jpg\" alt=\"\" width=\"1024\" height=\"576\"></div>\n"
+ "<p class=\"work-page__video_container\"><div class=\"video-embed\"><iframe src=\"https://player.vimeo.com/video/122136552\" width=\"500\" height=\"281\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe></div><br>\n"
+ "<div class=\"video-embed\"><iframe src=\"https://player.vimeo.com/video/122136232\" width=\"500\" height=\"281\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe></div></p>\n"
+ "<div class=\"image\"><a style=\"font-size: 20px;\" href=\"http://goldenarm.com/staging/wp-content/uploads/2015/06/Screen-Shot-2015-06-23-at-2.55.39-PM.png\"><img class=\"alignnone size-full wp-image-857\" src=\"http://goldenarm.com/staging/wp-content/uploads/2015/06/Screen-Shot-2015-06-23-at-2.55.39-PM.png\" alt=\"Screen Shot 2015-06-23 at 2.55.39 PM\" width=\"639\" height=\"638\"></a></div>";
final String subst = " $1";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
// The substituted value will be contained in the result variable
final String result = matcher.replaceAll(subst);
System.out.println("Substitution result: " + result);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html