[Solved] Parsing data from filename separated by a character

Post Reply
User avatar
gabrielp
Advanced member
Posts: 645
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.
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
bens
Advanced member
Posts: 282
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: 645
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-)
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Post Reply