I saw the following regex online and wanted to implement it into my Java Application (using java.util.regex).
(?<=(<Anhang>))(\w|\d|\n|[().,\-:;@#$%^&*\[\]"'+–/\/®°⁰!?{}|`~]| )+?(?=(<\/Anhang>))
This is supposed to match anything enclosed in '<Anhang>'
.
It works fine in a JavaScript engine but I can't get it to work in Java.
Here I tested it with a JavaScript engine on regex101 against this text:
BLALBLA BLA BLA <Anhang>
gonegone gone gone ,os .psd
</Anhang> ajdajadw
Which produced the following result:
So I went ahead and tried to use it in "Java Regular Expression Tester" but it either didn't match the Text or there was a Syntax error. I know that I have to escape certain characters but I just didn't get it to work, here is what I tried:
(?<=(<Anhang>))(\\w|\\d|\\n|[().,\-:;@#$%^&*\[\\]\"'+–/"/®°⁰!?{}|`~]| )+?(?=(<\"Anhang>))
(?<=(<Anhang>))(\\w|\\d|\\n|[().,\-:;@#$%^&*\[\\]\"'+–/"/®°⁰!?\{\}|`~]| )+?(?=(<\"Anhang>))
(?<=(<Anhang>))(\\w|\\d|\\n|[().,\\\\-:;@#$%^&*\[\\]\"'+–/"/®°⁰!?\{\}|`~]| )+?(?=(<\"Anhang>))