나는 용어집 목록에 대해 자바 문자열을 검사하려고 시도하고 용어집 목록에있는 용어를 찾으면 태그와 함께 용어를 감싼다. 그러나 문제는 용어집 목록에 두 개의 용어가있는 경우 : "Sprint"및 "Sprint 0"다음에 코드는 Sprint 용어 만 선택하고 "Sprint 0"은 무시한다는 것입니다.다른 문자열의 끝에 다른 단어가있는 다른 문자열을 찾는 방법은 무엇입니까?
여기 여기 내 코드
private String findGlassayTerms(String response, List<Glossary> glossary) {
for (Glossary item : glossary) {
// check if response contains the term
if (StringUtils.contains(response, item.getTerm())) {
System.out.println(item.getTerm());
response = StringUtils.replace(response, item.getTerm(), "<span class=" + item.getTerm() + ">" + item.getTerm() + "</span>");
}
}
return response;
}
입니다 결과입니다
<span class=Sprint>Sprint</span> 0 is typically a one or two week period at the end of the Define phase. <br>In summary, <span class=Sprint>Sprint</span> 0 provides an opportunity.
용어집을 가장 길게 정렬하는 것은 어떻습니까? – Axel
어떻게 도움이 될 수 있습니까? – user261002
글쎄, 당신은'Sprint' 전에'Sprint 0'을 대체하려고합니다. 왜냐하면 후자가 더 짧기 때문입니다. – Thomas