<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Yes, make a function called regexp which takes a regexp string and a haystack string and returns a BOOLEAN</p>
<p>I'm writing this without testing but...</p>
<p>sub run_regex<br>
{&nbsp;&nbsp;&nbsp; <br>
</p>
<p>&nbsp;&nbsp;&nbsp; my( $self, $state, $pattern, $haystack ) = @_;<br>
</p>
<p>&nbsp;&nbsp;&nbsp; my $regex = $pattern-&gt;[0];<br>
&nbsp;&nbsp;&nbsp; return [ $haystack-&gt;[0] =~ m/$regex/, &quot;BOOLEAN&quot; ];<br>
} <br>
</p>
<p><br>
</p>
<p>should give you a function where you can in the XML go&nbsp;</p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;when test=&quot;regex( 'International', event_title )&quot;&gt;</span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"><br>
</span></i></p>
<p>On 02/10/2019 14:49, John Salter via Eprints-tech wrote:</p>
<blockquote type="cite" cite="mid:EMEW3|5bf8819877e268fb9e75d9524f0df22fv91Epr14eprints-tech-bounces|ecs.soton.ac.uk|DB6PR0302MB271178FCF0638B0A8837B0F5C49C0@DB6PR0302MB2711.eurprd03.prod.outlook.com">
<meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Hi Stefan,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">You're right - it doesn't.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I don't think there is a simple way to achieve what you are trying to do with the EPScript methods available:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><a href="https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FEPScript&amp;data=01%7C01%7C%7C36c98e98823843c40d4d08d74741bc37%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=msCezdc%2FURhLB00q6MXSvGLllyfKyXJcr72l2vGE%2BIw%3D&amp;reserved=0" originalsrc="https://wiki.eprints.org/w/EPScript" shash="G5E7kg6QTP&#43;XTFQyzHIzS8N&#43;uy9r/Zsz&#43;4ozjwRsMSsdGqfiUeAXrlfgyCiaf3vc&#43;ZDGb/MFrny57a6UCYRMBB/RtKF6YT4C/BO/6iQpjv9dILRdWwIELgRcpQ7gcW4oWtyW&#43;KJIcIeVbV5zmBEwM&#43;xLioAGCGm9hDQs9VF3eVM=" originalsrc="https://wiki.eprints.org/w/EPScript" shash="KknvO1WiylbiLlvxX7c9ZM4BKaPHIlbJCkzmLzwIfWYxehJ8235/XGiiSot7DgWPRDLv8a/&#43;TRhjL5bUyXeyo8HVkWsbOPLiyy9b6UBpFTnWORi6EbBSNx3qd9wSvJeol5K0U7aAlPrp/XvT86WwdprL0EQj/i32REarklwYw58=" moz-do-not-send="true" title="Outlook Unmangled from:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.eprints.org%2Fw%2FEPScript&amp;data=01%7C01%7Ctotl%40soton.ac.uk%7Cbe247dce47eb42e9e4b208d7473fb3b0%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=SoknSgzXVeftqildDpg6P6h%2Bd8oWyqM429OKK9RbWfU%3D&amp;reserved=0">https://wiki.eprints.org/w/EPScript</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">If you look in EPrints::Script::Compiler::tokenise you'll see the different characters that EPScript expects - it doesn't include RegExps.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">You could inject a method to EPrints::Script::Compiled that returns a boolean for use in a test, or even rendered xhtml.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I used this approach here:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><a href="https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L11-L29&amp;data=01%7C01%7C%7C36c98e98823843c40d4d08d74741bc37%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=ZG8zXmB%2Feit8RNLDIJqPz4sUrkVhw2qegNwpgx0H60w%3D&amp;reserved=0" originalsrc="https://github.com/eprintsug/dimensions-badge/blob/master/lib/plugins/EPrints/Plugin/Screen/EPrint/Box/DimensionsBadge.pm#L11-L29" shash="ZgS5TYhvUIqnGTXGc3QAU49ZIvj0GOw42LSm/szD2JdO9qjU4sJaHYIHDbD6QqWdy6bsW8tL&#43;l7krObVsD/jDVkt1n0skqXu79g55NhA7cNlbHRl/jjty84eAMSJIYJuheVKx7ajBHG5ajgwr22V2yqkbgTVAy2FgqLzlT5uL&#43;s=" originalsrc="https://github.com/eprintsug/dimensions-badge/blob/master/lib/plugins/EPrints/Plugin/Screen/EPrint/Box/DimensionsBadge.pm#L11-L29" shash="lo9JVawCOxKCZ4vbhicQwBy9Up5YXADq9T7AHGYGZYSSUVqFYWmxqHHyBJbMmj5OPt3vQxnmlRDQEYjbMuUAPSbN3H8LffnRWUIxYUvzjDrHA9nwT6r1n&#43;2mTfQUVJSJ1MyMfp1be8MXgn7lz9UxuJ0wNbuL3xhWJ4x12BzUh2s=" moz-do-not-send="true" title="Outlook Unmangled from:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L11-L29&amp;data=01%7C01%7Ctotl%40soton.ac.uk%7Cbe247dce47eb42e9e4b208d7473fb3b0%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=%2F00Lmu9hSO0X9zOQxDtpYPn9w51AYD612dpOxzXzYL0%3D&amp;reserved=0">https://github.com/eprintsug/dimensions-badge/blob/master/lib/plugins/EPrints/Plugin/Screen/EPrint/Box/DimensionsBadge.pm#L11-L29</a>
 (documentation)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><a href="https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L117-L149&amp;data=01%7C01%7C%7C36c98e98823843c40d4d08d74741bc37%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=NLk7FpVYZfHODyWi88qDEm3h7p80bRiAVYFIRy5MUnM%3D&amp;reserved=0" originalsrc="https://github.com/eprintsug/dimensions-badge/blob/master/lib/plugins/EPrints/Plugin/Screen/EPrint/Box/DimensionsBadge.pm#L117-L149" shash="dHRWDGWN5c3pZUA9VguyNoOrMvpZ/PJgFRHAy73huQPfd7Aeq6b2F5Fsv3tDhxEI14sqatbG6w/OjZ4KHEos3k8Cce2oHZITqGyJcx/Q0CRPjtP&#43;lg4x42OtHJ63Cf2NN5/zUeIrONcMjVGJcZMle/ljFcx8EEwyvyfoJcyPAjw=" originalsrc="https://github.com/eprintsug/dimensions-badge/blob/master/lib/plugins/EPrints/Plugin/Screen/EPrint/Box/DimensionsBadge.pm#L117-L149" shash="bQHnPMvAVrhD59F4AZ/GCGQq4y3Do&#43;rSUUFNFqyImmt9k0bOcXOeNi20nhwkrKgpl5JMK3DDzoYx5yJqNomhx/p0Gjq7aJkxVqN90zLiw/iuyay0rq2veQPXEzj&#43;M3u&#43;TEq8DO6DuWVI/f5AwBpKx3kGLDI2xovMYOHbFO7CD9A=" moz-do-not-send="true" title="Outlook Unmangled from:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feprintsug%2Fdimensions-badge%2Fblob%2Fmaster%2Flib%2Fplugins%2FEPrints%2FPlugin%2FScreen%2FEPrint%2FBox%2FDimensionsBadge.pm%23L117-L149&amp;data=01%7C01%7Ctotl%40soton.ac.uk%7Cbe247dce47eb42e9e4b208d7473fb3b0%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=XS0pvfJfPWmuuEuj%2BDBrauCKwOuaAh3P1qoyy4JdFEw%3D&amp;reserved=0">https://github.com/eprintsug/dimensions-badge/blob/master/lib/plugins/EPrints/Plugin/Screen/EPrint/Box/DimensionsBadge.pm#L117-L149</a>
 (method added to EPrints::Script::Compiled)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Let me know if that helps - or if you want some more explanation.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">You *<b>could</b>* inject a method that took a RegExp as a parameter - you would need to be careful about compiling the regex from this string if you do!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">John<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1
            1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="mso-fareast-language:EN-GB" lang="EN-US">From:</span></b><span style="mso-fareast-language:EN-GB" lang="EN-US">
<a class="moz-txt-link-abbreviated" href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">
eprints-tech-bounces@ecs.soton.ac.uk</a> [<a class="moz-txt-link-freetext" href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">mailto:eprints-tech-bounces@ecs.soton.ac.uk</a>]
<b>On Behalf Of </b>Stefan Wellsandt via Eprints-tech<br>
<b>Sent:</b> 02 October 2019 14:27<br>
<b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:eprints-tech@ecs.soton.ac.uk">
eprints-tech@ecs.soton.ac.uk</a><br>
<b>Subject:</b> [EP-tech] Building citations based on condition with Regular Expression<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><span lang="EN-US">Hello,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I want to use a regular expression to assemble a part in a citation. This script (see below) throws me an error  I assume the EprintsScript does not know RegExp.
<o:p></o:p></span></p>
<p class="MsoNormal"><i><span lang="EN-US">&lt;when test=&quot;type.one_of('conference_item','editor_conference_proceeding')&quot;&gt;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp;&nbsp;&nbsp; In: Proceedings of the<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp;&nbsp;&nbsp; &lt;choose&gt;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;when test=&quot;event_title =~ \International\&quot;&gt;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;if test=&quot;event_title&quot;&gt;&lt;print expr=&quot;event_title&quot;/&gt;&lt;/if&gt;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/when&gt;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;otherwise&gt;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;if test=&quot;event_type&quot;&gt;&lt;print expr=&quot;event_type&quot;/&gt;&lt;/if&gt; on &lt;if test=&quot;event_title&quot;&gt;&lt;print expr=&quot;event_title&quot;/&gt;&lt;/if&gt;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/otherwise&gt;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp;&nbsp;&nbsp; &lt;/choose&gt;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">&nbsp; &lt;/when&gt;<o:p></o:p></span></i></p>
<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">What is the easiest way to fix this problem?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Best regards<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Stefan<o:p></o:p></span></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">*** Options: <a class="moz-txt-link-freetext" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a>
*** Archive: <a class="moz-txt-link-freetext" href="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.eprints.org%2Ftech.php%2F&amp;data=01%7C01%7C%7C36c98e98823843c40d4d08d74741bc37%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=T0cK9IHed5fOgK42wgHpbWKHr5mJK1PPCxiOINQ111k%3D&amp;reserved=0" originalsrc="http://www.eprints.org/tech.php/" shash="eXXKjmFaLah36/A512SQAAKcV0/uL3dcqsdvigtD6nEpyrPYIzeA9/HwIw2ENROT5pM4TVdBxE8zUMkfSGJk36BwIZBxOQB8GljMFRn7UkkCvxqZuU0&#43;8G/YjkIe9YZ4dnu7f/cLYAa4y1XWTjB4NLqvYAXYBtnaAUIXjwijVJQ=">http://www.eprints.org/tech.php/</a>
*** EPrints community wiki: <a class="moz-txt-link-freetext" href="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwiki.eprints.org%2F&amp;data=01%7C01%7C%7C36c98e98823843c40d4d08d74741bc37%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=U8FNs%2F0WR81dQjjAr%2BS%2BTYHZ1tpjdw7Fe%2B7i2zC91is%3D&amp;reserved=0" originalsrc="http://wiki.eprints.org/" shash="NjWx8oG8lbc0vlRNNIbFvaU9xgZLcO6Z18HQpBrNQsU&#43;BQqQU3ZSq7zMmnuvn9BEoILY6Cn/h2E1GEgqFXSoFOMBL8OmnkxkG4cT9ja5q4gNa1dw&#43;MZiuYlX5sIBgu8hRj1MrPLfzecB/cntF7A9&#43;Bub4anWZ1giavixPNrZwEo=">http://wiki.eprints.org/</a>
*** EPrints developers Forum: <a class="moz-txt-link-freetext" href="https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fforum.eprints.org%2F&amp;data=01%7C01%7C%7C36c98e98823843c40d4d08d74741bc37%7C4a5378f929f44d3ebe89669d03ada9d8%7C0&amp;sdata=YBWGH4n8wqKDQ2IlR2QAmWvi6rrFyio8G2aWRR8NuGc%3D&amp;reserved=0" originalsrc="http://forum.eprints.org/" shash="FjI95e&#43;KSQyqSQxP6IOjdFKvtJI/8PgDYWYRKk7X&#43;OyDvgMtvUeGPQN/eJE2tUqaNa&#43;LIadiMQE53inGfyxrzlphqnQ5rRKFPe9lIEhCGy0LDlSZBYbTW1fqcmw/1zQ4KQlREt8&#43;N04sup633sBvZVmBNOzndXDbQN3eIHxJr6I=">http://forum.eprints.org/</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">-- 
Christopher Gutteridge <a class="moz-txt-link-rfc2396E" href="mailto:totl@soton.ac.uk">&lt;totl@soton.ac.uk&gt;</a> 
You should read our team blog at <a class="moz-txt-link-freetext" href="http://blog.soton.ac.uk/webteam/">http://blog.soton.ac.uk/webteam/</a></pre>
</body>
</html>