0

Hi I have a Stylesheet where i use xsl:analyze-string with the following regex:

(&journal_abbrevs;)[\s ]*([0-9]{{4}})[,][\s ][S]?[\.]?[\s ]?([0-9]{{1,4}})([\s ][(][0-9]{{1,4}}[)])?

You don't need to look at the whole thing :)

&journal_abbrevs; looks like this:

"example-String1|example-String2|example-String3|..."

What I need to do know is exclude one of the strings in &journal_abbrevs; from this regex. E.g. I don't want example-String1 to be matched.

Any ideas on how to do that ?

pypat
  • 1,096
  • 1
  • 9
  • 19

1 Answers1

0

It seems XSLT regex does not support look-around. So I don't think you'll be able to get a solution for this that does not involve writing out all strings from journal_abbrevs in your regex. Related question.

To minimize the amount of writing out, you could split journal_abbrevs into say journal_abbrevs1, journal_abbrevs2 and journal_abbrevs3 (or how many you decide to use) and only write out whichever one that contains the string you wish to exclude. If journal_abbrevs1 contains the string, you'd then end up with something like:

((&journal_abbrevs2;)|(&journal_abbrevs3;)|example-String2|example-String3|...)...

If it supported look-around, you could've used a very simple:
(?!example-String1)(&journal_abbrevs;)...

Community
  • 1
  • 1
Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138
  • Thank you for your answer but it seems that xslt does not support this. If I try (?!example-String1)(&journal_abbrevs;)[\s ]*... the stylesheet can't be compiled anymore. – pypat Jun 13 '13 at 09:06
  • I had already thought of that but i hoped there was a more elegant solution. I guess I'll have to go with it. – pypat Jun 13 '13 at 09:40