Mapping more than one additional RIS field


(Lyndon Drake) #1

This is a followup question to a couple of older threads. I’ve managed to get the following code from this thread working:

if($ReferenceRIS.contains("Z1  -")){
  $ReferenceRIS.contains("Z1  - ([^\n]*)\n");
  $CiteKey=$1.replace("Z1  - ","").replace("\n","")
}
else {$CiteKey=""};

But if I then amend the rule as follows:

if($ReferenceRIS.contains("Z1  -")){
  $ReferenceRIS.contains("Z1  - ([^\n]*)\n");
  $CiteKey=$1.replace("Z1  - ","").replace("\n","")
}
else {$CiteKey=""};
if($ReferenceRIS.contains("Z2  -")){
  $ReferenceRIS.contains("Z2  - ([^\n]*)\n");
  $ReferenceURL=$2.replace("Z2  - ","").replace("\n","")}
else {$ReferenceURL=""}

Then ReferenceURL ends up with the contents of the Z1 field, not the Z2 field. I guess I should be using something other than $2 to get the contents of the regex match, but I have no idea what to use?


(eastgate) #2

Could you send me a short but comprehensive email of what you’re trying to do — exactly what sort of reference you want to import, along with an example or two of typical RIS? bernstein@eastgate.com


(Lyndon Drake) #3

Just as an FYI: this got sorted - very helpful support from Mark.


(eastgate) #4

The key to the answer is to search for all the fields in one regular expression; this gives the first sub-expression in $1, the second in $2, and so forth.