[Solved] Parsing data from filename separated by a character

Post Reply
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

[Solved] Parsing data from filename separated by a character

Post by gabrielp »

Is there an easy way to pull values from the jobNameProper with separators in this format?
Image

Essentially I need a way to capture the first, second, third, and fourth value separated by an underscore.
Last edited by gabrielp on Mon Mar 23, 2015 5:42 pm, edited 1 time in total.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
bens
Member
Posts: 130
Joined: Thu Mar 03, 2011 10:13 am

Re: Parsing data from filename separated by a character

Post by bens »

You'll probably need a regular expression; I don't think the string manipulation for variables is strong enough.

Do you have the scripting module? If so, you can use this:

Code: Select all

var theRegex = /(.*)_(.*)_(.*)_(.*)_.*/;
theRegex.search( job.getNameProper() );
var theCompleteMatch = theRegex.cap(0);
var thePlateID = theRegex.cap(1);
//...
User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: Parsing data from filename separated by a character

Post by gabrielp »

Thanks man. Exactly what I was looking for. I have an e-book on regex I have had for a while now. Maybe it's time to finally read it. 8-)
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Post Reply