Regex doesn't match

I have problems with regexp in this situation: I need to extract (and replace) all points from such a construction:

any_symbols->white_space->x.(or xx. or Xx. or xX. or xy. or yy. etc.)->white_space->any_symbol_not_upper_case_and_not_a_digit 

eg

 1990 x. abcd - extract dot ffff xx.abcd - extract dot 1990 x. Abcdef - do not extract abcd x. Abcd - do not extract abcd x. 1990 - do not extract 

So, I created such a regex:

 (?<=\s[XxYy]{1,2})\.(?>=\s+?[^\p{javaUpperCase}\d]) 

But that does not match. So what's wrong?

thanks

PS

After

 String skipPtrn="(?<=\\s[]{1,2})\\.(?>=\\s+?[^\\p{javaUpperCase}\\d])"; originalText=originalText.replaceAll(skipPtrn, " "); 

I still find the text:

1673 p. appearing

At 1623 p. across

at 1925 p. ("Visnik

and etc.

+4
source share
2 answers

Try removing the > character from the search group forward: (?<=\s[XxYy]{1,2})\.(?=\s+?[^\p{javaUpperCase}\d]) . You can do (?>x) (atomic group) or (?=x) (positive with zero width), but not (?>=x) .

Also note that your second example does not match your description and will not match the expression above.

+2
source

Look ahead no need at all:

 $ perl -wne 's/^(\w+\s+[XxYy]{1,2})\.(\s*[^AZ\d]+)$/$1$2/;print' <data.txt 1990 x abcd ffff xxabcd 1990 x. Abcdef abcd x. Abcd abcd x. 1990 
+1
source

All Articles