/*
60 | * excelFormulaUtilitiesJS
61 | * https://github.com/joshatjben/excelFormulaUtilitiesJS/
62 | *
63 | * Copyright 2011, Josh Bennett
64 | * licensed under the MIT license.
65 | * https://github.com/joshatjben/excelFormulaUtilitiesJS/blob/master/LICENSE.txt
66 | *
67 | * Some functionality based off of the jquery core lib
68 | * Copyright 2011, John Resig
69 | * Dual licensed under the MIT or GPL Version 2 licenses.
70 | * http://jquery.org/license
71 | *
72 | * Based on Ewbi's Go Calc Prototype Excel Formula Parser. [http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html]
73 | */
74 |
75 | (function () {
76 |
77 | if (typeof window === 'undefined') {
78 | window = root;
79 | }
80 | var excelFormulaUtilities = window.excelFormulaUtilities = window.excelFormulaUtilities || {};
81 | var core = window.excelFormulaUtilities.core = {};
82 | window.excelFormulaUtilities.string = window.excelFormulaUtilities.string || {};
83 |
84 | /**
85 | * Simple/quick string formater. This will take an input string and apply n number of arguments to it.
86 | *
87 | * <b>example:</b><br />
88 | * <code>
89 | * <pre>
90 | * var foo = excelFormulaUtilities.core.formatStr("{0}", "foo"); // foo will be set to "foo"
91 | * var fooBar = excelFormulaUtilities.core.formatStr("{0} {1}", "foo", "bar"); // fooBar will be set to "fooBar"
92 | * var error = excelFormulaUtilities.core.formatStr("{1}", "error"); // will throw an index out of range error since only 1 extra argument was passed, which would be index 0.
93 | * </pre>
94 | * </code>
95 | *
96 | * @memberOf window.excelFormulaUtilities.core
97 | * @function
98 | * @param {String} inStr
99 | **/
100 | var formatStr = window.excelFormulaUtilities.string.formatStr = function(inStr) {
101 | var formattedStr = inStr;
102 | var argIndex = 1;
103 | for (; argIndex < arguments.length; argIndex++) {
104 | var replaceIndex = (argIndex - 1);
105 | var replaceRegex = new RegExp("\\{{1}" + replaceIndex.toString() + "{1}\\}{1}", "g");
106 | formattedStr = formattedStr.replace(replaceRegex, arguments[argIndex]);
107 | }
108 | return formattedStr;
109 | };
110 |
111 | var trim = window.excelFormulaUtilities.string.trim = function(inStr){
112 | return inStr.replace(/^\s|\s$/, "");
113 | };
114 |
115 | var trimHTML = window.excelFormulaUtilities.string.trim = function(inStr){
116 | return inStr.replace(/^(?:\s| |<\s*br\s*\/*\s*>)*|(?:\s| |<\s*br\s*\/*\s*>)*$/, "");
117 | };
excelFormulaUtilities.formatFormula( "" );
75 | 76 |excelFormulaUtilities.formatFormulaHTML( "" );
80 |
81 | excelFormulaUtilities.formula2CSharp( "" );
85 |
86 | excelFormulaUtilities.formula2Javascript( "" );
90 |
91 |