I need to write a regular expression in order to use it in java using pattern and matcher. the regular expression should test if a word inside a text is surrounded by javascript tags. For examples, lets say i have the following text:
**testtesttesttest <script> example of a "text" </script> testtesttesttest**
and i need to check if the word "text" is surrounded by <script> and </script>.
I have split the text to have two texts:
txt1 = testtesttesttest <script> example of a
txt2 = </script> testtesttesttest
Now i need to check:
- if txt1 contains the tag <script> but does not contain after it a tag </script>
- if txt2 contains the tag </script> but does not contain before it a tag <script>
Is there a way to do it using the regular expression? Thank you in advance,