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
-
- Advanced member
- Posts: 230
- Joined: Thu Aug 07, 2014 10:04 am
Regular Expressions within metadata variables
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);
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
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
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
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
[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