Tôi có văn bản với nhiều cụm từ #{key}
. Ví dụ:Làm thế nào để thay thế tất cả # {key} thành chuỗi?
Lorem ipsum dolor sit amet, consectetur adipisicing #{key1}. Proin nibh
augue, suscipit a, scelerisque #{key1}, lacinia in, mi. Cras vel #{key2}.
Etiam pellentesque aliquet tellus. Phasellus pharetra nulla ac diam.
Quisque semper #{key3} at risus.
tôi cần phải thay thế tất cả #{key}
giá trị tương ứng với messageSource.getMessage(key, null, locale)
(messageSource
là org.springframework.context.MessageSource), nhưng tôi không giỏi regex. Làm thế nào để xây dựng đúng biểu thức chính quy?
Ví dụ:
#{texts.appName} need to replace with messageSource.getMessage("texts.appName", null, locale);
#{my.company} need to replace with messageSource.getMessage("my.company", null, locale);
Xem câu trả lời của tôi! :) – HashimR
nhìn vào lớp String trong api nó sẽ cho bạn biết tất cả những gì bạn cần – lancegerday