Changeset 5534
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/StringUtil.java
r5519 r5534 182 182 regular expression, optionally ignoring matches that are inside 183 183 quotes. 184 184 185 @param s The string to tokenize 185 186 @param regexp The regular expression for matching split sites 187 @param notInsideQuotes If TRUE, the regexp is not matched inside quotes 186 188 @return An array with the elements of the array 187 189 @since 2.15 188 190 */ 189 public static final String[] tokenize(String s, String regexp, boolean notInsideQoutes) 191 public static final String[] tokenize(String s, String regexp, boolean notInsideQuotes) 192 { 193 return tokenize(s, regexp, notInsideQuotes, false); 194 } 195 196 /** 197 Tokenize a string by splitting it at positions matching the 198 regular expression. Matches that are inside quotes can optionally 199 be ignored. Elements with quotes can optionally have the quotes 200 removed. 201 202 @param s The string to tokenize 203 @param regexp The regular expression for matching split sites 204 @param notInsideQuotes If TRUE, the regexp is not matched inside quotes 205 @param removeQuotes If TRUE, remove quotes from all elements before returning the 206 result 207 208 @return An array with the elements of the array 209 @since 2.17 210 */ 211 public static final String[] tokenize(String s, String regexp, boolean notInsideQuotes, boolean removeQuotes) 190 212 { 191 213 String[] result = null; 192 214 if (s != null && regexp != null) 193 215 { 194 if (notInsideQ outes) regexp += "(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))";216 if (notInsideQuotes) regexp += "(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))"; 195 217 result = s.split(regexp); 218 if (removeQuotes) 219 { 220 for (int i = 0; i < result.length; ++i) 221 { 222 String t = result[i]; 223 if (t != null && t.startsWith("\"") && t.endsWith("\"")) 224 { 225 result[i] = t.substring(1, t.length()-1); 226 } 227 } 228 } 196 229 } 197 230 return result; 198 231 } 199 232 200 233 201 234 /** -
trunk/src/plugins/core/net/sf/basedb/plugins/executor/ExternalProgramExecutor.java
r5481 r5534 721 721 if (cmdLine != null) 722 722 { 723 // Split on whitespace but not inside quotes 724 cmds.addAll(Arrays.asList(StringUtil.tokenize(cmdLine, "\\s+", true))); 723 // Split on whitespace but not inside quotes; quotes are removed 724 String[] options = StringUtil.tokenize(cmdLine, "\\s+", true, true); 725 if (options != null) 726 { 727 cmds.addAll(Arrays.asList(options)); 728 } 725 729 } 726 730 builder.command(cmds);
Note: See TracChangeset
for help on using the changeset viewer.