Page 1 of 1

command to string search?

Posted: Mon Jun 05, 2017 1:10 pm
by sherimc
Hello,

I am wanting to use the #fileDescription to name procedures in my MVC template; however, I need the ability to "scan" and "replace" unnecessary characters. Is there a way to do this that I am not aware of currently?

For example, our file description looks like this: SO-Shipments-Header Level Tax Info

I want to squeeze out the hyphens and spaces.

Thanks,
Sheri McPherson

Re: command to string search?

Posted: Tue Jun 06, 2017 10:29 am
by matt.denninghoff
Yes, there is a relatively new template directive, #eval, which allows you to use javascript in the pre-processing phase. So if you were to use the JavaScript replace function, then you can remove spaces and dashes with this:

Code: Select all

#eval("#fileDescription".replace(/[- ]/g,""))
Then the resulting file description would be: SOShipmentsHeaderLevelTaxInfo

The form of replace above uses a Regular Expression with the "global" flag, to match and replace all instances of either "-" or " ". #eval came out with Profound UI version 5.7.0.

Re: command to string search?

Posted: Tue Jun 06, 2017 11:28 am
by sherimc
Matt,

Thank you very much for letting me know! I have very limited experience with JavaScript am a RPG programmer trying to use Jumpstart. Your help is greatly appreciated.