import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "<\\/p><p>.*>(.+?)<.*[:-] (.*)";
final String string = "</p><p><b><a href=\"/index.php/AGS\" title=\"AGS\">AGS</a></b>: Amazon Global Store\n"
+ "</p><p><b><a href=\"/index.php?title=APPH&action=edit&redlink=1\" class=\"new\" title=\"APPH (page does not exist)\">APPH</a></b>: Actual Pick Rate\n"
+ "</p><p><b>APV</b>: Amazon Prime Video\n"
+ "</p><p><b><a href=\"/index.php?title=ASK_ID&action=edit&redlink=1\" class=\"new\" title=\"ASK ID (page does not exist)\">ASK ID</a></b>: Alexa Skills Kit International Data\n"
+ "</p><p><b><a href=\"/index.php/AWS\" title=\"AWS\">AWS</a></b>: Advertiser Web Services\n"
+ "</p><p><b><a href=\"/index.php/CBP\" title=\"CBP\">CBP</a></b>: Cross Border Pricing\n"
+ "</p><p><b><a href=\"/index.php/CDF\" title=\"CDF\">CDF</a></b>: Cumulative Distribution Function\n"
+ "</p><p><b><a href=\"/index.php?title=CVSD&action=edit&redlink=1\" class=\"new\" title=\"CVSD (page does not exist)\">CVSD</a></b>: Convenience Store Delivery\n"
+ "</p><p><b><a href=\"/index.php/CWGR\" title=\"CWGR\">CWGR</a></b>: Compound Weekly Growth Rate\n"
+ "</p><p><b>DEXTER</b>: Delivery Execution Tracking Evaluation and Reconciliation\n"
+ "</p><p><b><a href=\"/index.php?title=DMI&action=edit&redlink=1\" class=\"new\" title=\"DMI (page does not exist)\">DMI</a></b>: Desktop Management Interface\n"
+ "</p><p><b>DNB</b>: Digital Native Business (AWS)\n"
+ "</p><p><b>eCPDPV</b>: effective Cost Per Detail Page View\n"
+ "</p><p><b>EOR</b>: Exporter of Record (see also IOR)\n"
+ "</p><p><b>FAST</b>: Flexible Accelerated Recruiting Team (Consumer Talent)\n"
+ "</p><p><b>FEC</b>: FC execution cluster/system\n"
+ "</p><p><a href=\"https://w.amazon.com/index.php/TranslationTeam\" class=\"external text\" rel=\"nofollow\"><b>FL</b></a>: Freelance Translation Specialist\n"
+ "</p><p><b><a href=\"/index.php?title=FMM&action=edit&redlink=1\" class=\"new\" title=\"FMM (page does not exist)\">FMM</a></b>: Field Marketing Manager (AWS)\n"
+ "</p><p><b>FQ</b>: Feature Question (ORR)\n"
+ "</p><p><b><a href=\"/index.php/FRA3\" title=\"FRA3\">FRA3</a></b>: Second FC, Bad Hersfeld\n"
+ "</p><p><b>FRT</b>: First Response Time\n"
+ "</p><p><b>FSSS</b>: Free Super Saver Shipping\n"
+ "</p><p><b>G/NG</b>: Go/No Go\n"
+ "</p><p><b><a href=\"/index.php?title=GOE&action=edit&redlink=1\" class=\"new\" title=\"GOE (page does not exist)\">GOE</a></b>: Global Optimization Engine\n"
+ "</p><p><a href=\"https://w.amazon.com/index.php/Ingenii\" class=\"external text\" rel=\"nofollow\"><b>INGENII</b></a>: Amazon's Career's growth plan tool\n"
+ "</p><p><b>IN</b>: India Marketplace\n"
+ "</p><p><b><a href=\"/index.php/Ion\" title=\"Ion\">ION</a></b>: Inter-operable Object Notation\n"
+ "</p><p><b>IOR</b>: Importer of Record (see also EOR)\n"
+ "</p><p><b><a href=\"/index.php?title=LCPO&action=edit&redlink=1\" class=\"new\" title=\"LCPO (page does not exist)\">LCPO</a></b>: Low Confidence Purchase Order\n"
+ "</p><p><b>LRR</b>: Launch Readiness Review\n"
+ "</p><p><b><a href=\"/index.php?title=MQL&action=edit&redlink=1\" class=\"new\" title=\"MQL (page does not exist)\">MQL</a></b>: Marketing Qualified Lead (AWS)\n"
+ "</p><p><b><a href=\"/index.php/MUC3\" title=\"MUC3\">MUC3</a></b>: FC, Graben\n"
+ "</p><p><b>OLVCS</b>: Offer Level VAT Calculation Services\n"
+ "</p><p><b><a href=\"/index.php?title=P2S&action=edit&redlink=1\" class=\"new\" title=\"P2S (page does not exist)\">P2S</a></b>: Propensity to Spend (AWS)\n"
+ "</p><p><a href=\"https://w.amazon.com/index.php/B2B/ProfessionalLicensing\" class=\"external text\" rel=\"nofollow\"><b>PLP</b></a>: Professional Licensing Program\n"
+ "</p><p><b><a href=\"/index.php/RAP\" title=\"RAP\">RAP</a></b>: Recruiter Academy Program (Consumer Talent)\n"
+ "</p><p><b><a href=\"/index.php/RHEL\" title=\"RHEL\">RHEL</a></b>: Red Hat Enterprise Linux\n"
+ "</p><p><b><a href=\"/index.php/RFV\" title=\"RFV\">RFV</a></b>: Resolving For Visibility\n"
+ "</p><p><b><a href=\"/index.php/RHMD\" title=\"RHMD\">RHMD</a></b>: Recruiter How's My Driving\n"
+ "</p><p><b><a href=\"/index.php/SLCS\" title=\"SLCS\">SLCS</a></b>: <a href=\"/index.php/SourcingLandedCostService\" title=\"SourcingLandedCostService\">Sourcing Landed Cost Service</a> (See also <b><a href=\"/index.php/LandedCost\" title=\"LandedCost\">Landed Cost</a></b>)\n"
+ "</p><p><b><a href=\"/index.php/SRL\" title=\"SRL\">SRL</a></b>: Start Reading Location, a feature on Kindle that opens ebooks to the title page, for KiM titles it's set to the cover page so the customer can view the illustrated motion\n"
+ "</p><p><b><a href=\"/index.php/SSX\" title=\"SSX\">SSX</a></b>: Shared Shopping Experience\n"
+ "</p><p><b><a href=\"/index.php/SQL\" title=\"SQL\">SQL</a></b>: Sales Qualified Lead (AWS)\n"
+ "</p><p><b><a href=\"https://w.amazon.com/index.php/TranslationTeam\" class=\"external text\" rel=\"nofollow\">TS</a></b>: Translation Specialist\n"
+ "</p><p><b><a href=\"/index.php/VAS\" title=\"VAS\" class=\"mw-redirect\">VAS</a></b>: Value Added Services <b><a href=\"https://w.amazon.com/bin/view/ValueAddedServices/Glossary/\" class=\"external text\" rel=\"nofollow\">(VAS Specific Acronyms)</a></b>\n"
+ "</p><p><b><a href=\"/index.php/VF\" title=\"VF\">VF</a></b>: Vinnige Fanie";
final String subst = "$1 - $2";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
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