Hi Mike,

The documentation (which seems not to have updated on the site yet) says
the following:

>>>>>>
                <p>You can also use regular expressions in the substitution
string, for example: "${there|[0-9]*}", which will extract the first
sequence of sequential numbers it finds in the
                      value of the field "there", or
"${there|string(.*)|1}", which will include everything following "string"
in the field value.  (The third argument specifies the regular
                      expression group number, with an optional suffix of
"l" or "u" meaning upper-case or lower-case.)</p>
                <p>Enter a parameter name, and either select to remove the
value or provide an expression.  If you chose to supply an expression,
enter the expression in the box.
<<<<<<

To evaluate your regular expression with the specific input you gave, I
typically use a regex applet, if you can find a browser that still allows
it:

http://www.cis.upenn.edu/~matuszek/General/RegexTester/regex-tester.html

Dropping your stuff in and clicking the "find()" button yields this:
"Pattern did not match"

So your regex is not correct.  But, "Protocol (\d+)" does match, with the
following group outputs:

start() = 0, end() = 16
group(0) = "Protocol 1234500"
group(1) = "1234500"

So you want group 1.  Therefore, the MCF expression would be:

expression = Protocol-${protocol_name|Protocol (\d+)|1}

Thanks,
Karl



On Tue, Aug 18, 2015 at 11:19 PM, Mike Caceres <[email protected]>
wrote:

> If I have a document with the following metadata values:
> "protocol_name" : "Protocol 1234500 (USPA00012345) second version"
>
> and I want to produce a new metadata field that looks like this:
>
> "protocol_id" : "Protocol-1234500"
>
> should the metadata expression look like this?
>
> parameter name = protocol_id
> remove this parameter = false
> expression = Protocol-${protocol_name|string(\d+)|0}
>
> Thank you!
>

Reply via email to