@@ -205,4 +205,57 @@ public void testEquals() {
205205 assertThat (pattern1 .hashCode ()).isEqualTo (pattern2 .hashCode ());
206206 assertThat (pattern1 ).isNotEqualTo (pattern4 );
207207 }
208+
209+ @ Test
210+ public void testUnicodeWordBoundary () {
211+ final String pattern = "l\\ p{L}*\\ b" ;
212+ final String text = "l\u00E0 " ;
213+ {
214+ final java .util .regex .Matcher matcher =
215+ java .util .regex .Pattern .compile (pattern ).matcher (text );
216+ assertEquals (true , matcher .find ());
217+ assertEquals ("l\u00E0 " , text .substring (matcher .start (), matcher .end ()));
218+ }
219+ {
220+ final com .google .re2j .Matcher matcher =
221+ com .google .re2j .Pattern .compile (pattern ).matcher (text );
222+ assertEquals (true , matcher .find ());
223+ assertEquals ("l\u00E0 " , text .substring (matcher .start (), matcher .end ()));
224+ }
225+ }
226+
227+ @ Test
228+ public void testUnicodeWordBoundary2 () {
229+ final String pattern = "d\u00E9 \\ p{L}*\\ b" ;
230+ {
231+ final String text = "d\u00E9 s" ;
232+ {
233+ final java .util .regex .Matcher matcher =
234+ java .util .regex .Pattern .compile (pattern ).matcher (text );
235+ assertEquals (true , matcher .find ());
236+ assertEquals ("d\u00E9 s" , text .substring (matcher .start (), matcher .end ()));
237+ }
238+ {
239+ final com .google .re2j .Matcher matcher =
240+ com .google .re2j .Pattern .compile (pattern ).matcher (text );
241+ assertEquals (true , matcher .find ());
242+ assertEquals ("d\u00E9 s" , text .substring (matcher .start (), matcher .end ()));
243+ }
244+ }
245+ {
246+ final String text = "d\u00E9 " ;
247+ {
248+ final java .util .regex .Matcher matcher =
249+ java .util .regex .Pattern .compile (pattern ).matcher (text );
250+ assertEquals (true , matcher .find ());
251+ assertEquals ("d\u00E9 " , text .substring (matcher .start (), matcher .end ()));
252+ }
253+ {
254+ final com .google .re2j .Matcher matcher =
255+ com .google .re2j .Pattern .compile (pattern ).matcher (text );
256+ assertEquals (true , matcher .find ());
257+ assertEquals ("d\u00E9 " , text .substring (matcher .start (), matcher .end ()));
258+ }
259+ }
260+ }
208261}
0 commit comments