@Test public void withoutTags() { Document expected = new Document("Sentence 1Sentence 2"); Document with = new Document( "<div id=\"id\"><p>Sentence 1<br>Sentence 2</p></div>" ); Document without = with.withoutTags(); assertEquals(expected.toString(), without.toString()); }
public Document withoutTags() { Pattern pattern = Pattern.compile(">([\\w\\d\\s]+)<"); Matcher matcher = pattern.matcher(data); StringBuffer buffer = new StringBuffer(); while (matcher.find()) buffer.append(matcher.group(1)); return new Document(buffer.toString()); }
Document { public Document withoutTags() { Pattern pattern = Pattern.compile(">([\\w\\d\\s]+)<"); Matcher matcher = pattern.matcher(data); StringBuffer buffer = new StringBuffer(); while (matcher.find()) buffer.append(matcher.group(1)); return new Document(buffer.toString()); } }
Document { public Document withoutTags() { Pattern pattern = Pattern.compile(">([\\w\\d\\s]+)<"); Matcher matcher = pattern.matcher(data); StringBuffer buffer = new StringBuffer(); while (matcher.find()) buffer.append(matcher.group(1)); return new Document(buffer.toString()); } Document(String data); }
Document { public Document withoutTags() { Pattern pattern = Pattern.compile(">([\\w\\d\\s]+)<"); Matcher matcher = pattern.matcher(data); StringBuffer buffer = new StringBuffer(); while (matcher.find()) buffer.append(matcher.group(1)); return new Document(buffer.toString()); } Document(String data); Document withoutTags(); @Override String toString(); @Override boolean equals(Object object); }
Document { public Document withoutTags() { Pattern pattern = Pattern.compile(">([\\w\\d\\s]+)<"); Matcher matcher = pattern.matcher(data); StringBuffer buffer = new StringBuffer(); while (matcher.find()) buffer.append(matcher.group(1)); return new Document(buffer.toString()); } Document(String data); Document withoutTags(); @Override String toString(); @Override boolean equals(Object object);  }