Page 1 of 1

Regular Expressions within metadata variables

Posted: Mon Nov 24, 2014 12:09 pm
by janwolk
dear all,



I'd like to capture the inital Chars from a string like "Jan Wolk" and glue it to a Ordnernummer catched out of a JDF file.



[Metadata.Text:Path="/jdf:JDF/@JobID",Dataset="Jdf",Model=JDF][Metadata.Text:Path="/jdf:JDF/jdf:AuditPool[1]/jdf:Created/@Author",Dataset="Jdf",Model="JDF",Search="[A-Z]{1}"][Metadata.Text:Path="/jdf:JDF/jdf:AuditPool[1]/jdf:Created/@Author",Dataset="Jdf",Model="JDF",Search="s[A-Z]{1}"]



this returns a string like "1234567 JW" but i need it without whitespace. I playes around with capture groups and anchors and so on, but i couldn't get rid of the whitespace...



Unfortuantely poitive lookbehinds are not supported by javascript, so are there any workarounds?



thank you in advance!!



regards, Jan

Regular Expressions within metadata variables

Posted: Mon Nov 24, 2014 1:09 pm
by ArielRauch
do you have access to scripting module?



Try this - have done blind - so do not accuse me on syntax errors:)



var jobID = job.getVariableAsString("[Metadata.Text:Path="/jdf:JDF/@JobID",Dataset="Jdf",Model=JDF]") ;

var author = job.getVariableAsString("[Metadata.Text:Path="/jdf:JDF/jdf:AuditPool[1]/jdf:Created/@Author",Dataset="Jdf",Model="JDF"]");



var authName = author.split(" ");

var ordNum = jobID + authName[0].left(1) + authName[1].left(1);

Regular Expressions within metadata variables

Posted: Mon Nov 24, 2014 1:34 pm
by freddyp
You should combine the Search for the first letter of the last name with "After" " "(space).



The manipulations of the string are done from top to bottom. As "Before" and "After" come first, the string is already changed by the time of the "Search" with the regular expression.



Freddy

Regular Expressions within metadata variables

Posted: Mon Nov 24, 2014 2:07 pm
by janwolk
Thanks Freddy, Ariel,



[Metadata.Text:Path="/jdf:JDF/@JobID",Dataset="Jdf",Model=JDF][Metadata.Text:Path="/jdf:JDF/jdf:AuditPool[1]/jdf:Created/@Author",Dataset="Jdf",Model="JDF",After=" ",Search="[A-Z]{1}"][Metadata.Text:Path="/jdf:JDF/jdf:AuditPool[1]/jdf:Created/@Author",Dataset="Jdf",Model="JDF",Search="[A-Z]{1}"]



-->After=" "<--



did the trick. Now i get 1234567JW, thats it. Thank you very much! I didn't use the script expression, because i allways try to make it as simple as possible...



regards, Jan