/** * Replaces ${xxx} with corresponding env variable for the specified val. * * @param val the specified val * @return replaced val */ private static String replaceEnvVars(final String val) { String ret = val; final String[] envVars = StringUtils.substringsBetween(ret, "${", "}"); if (null != envVars) { for (int i = 0; i < envVars.length; i++) { final String envKey = envVars[i]; String envVal = System.getenv(envKey); if (StringUtils.isBlank(envVal)) { envVal = ""; } ret = StringUtils.replace(ret, "${" + envKey + "}", envVal); } } return ret; }
/** * In case when bb code contains tag [user], text processing execute with help * this method because KefirrBB does not work properly * with eg "[user=/jcommune/users/16][user]user[/user][/user]" i.e user name contains tag [user] * @param bbEncodedText line with nested [user] bb-codes * @return formatted text with link */ private String processUserbbCode(String bbEncodedText) { String openTag = "<a href=\""; String closeTag = "</a>"; String classInfo = "\" class=\"mentioned-user\" >"; String[] array = StringUtils.substringsBetween(bbEncodedText, "[", "]"); String userLink = array[0]; String userName = bbEncodedText.substring(userLink.length() + 2, bbEncodedText.length() - 7); String result = openTag + userLink.substring(5, userLink.length()) + classInfo + userName + closeTag; return result; } }
public static String removeHTMLTagsFromStr(String inputStr) { String[] removeTags = StringUtils.substringsBetween(inputStr, "<", ">"); if (removeTags != null && removeTags.length > 0) { for (String tag : removeTags) { inputStr = StringUtils.remove(inputStr, "<" + tag + ">"); } } return inputStr; }
/** * Replaces ${xxx} with corresponding env variable for the specified val. * * @param val the specified val * @return replaced val */ private static String replaceEnvVars(final String val) { String ret = val; final String[] envVars = StringUtils.substringsBetween(ret, "${", "}"); if (null != envVars) { for (int i = 0; i < envVars.length; i++) { final String envKey = envVars[i]; String envVal = System.getenv(envKey); if (StringUtils.isBlank(envVal)) { envVal = ""; } ret = StringUtils.replace(ret, "${" + envKey + "}", envVal); } } return ret; }
public List<String> extractEntriesFromSpecial_Export(String filename){ List<String> filteredEntries = new ArrayList<String>(); String content=null; try { content = FileUtils.readFileToString(new File(filename)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } String[] entries = StringUtils.substringsBetween(content, "[[", "]]"); for(String e: entries){ if (e.startsWith("Kategorie") || e.startsWith("Category") || e.startsWith("d:") || e.startsWith("User") ||e.startsWith("Portal") ) continue; if (e.indexOf(':')>-1) continue; if (e.indexOf(":")>-1) continue; int endofEntry = e.indexOf('|'); if (endofEntry>-1) e = e.substring(0, endofEntry); filteredEntries.add(e); } filteredEntries = new ArrayList<String> (new HashSet<String>(filteredEntries)); return filteredEntries; }
/** * Given a include/exclude string. fetch the test expression * * @param teststr * @return a substring of a test expression * @throws BadFormDesignException * @should extract the correct expression from teststr */ public static String getTestStr(String teststr) throws BadFormDesignException { if (StringUtils.isBlank(teststr)) throw new BadFormDesignException("Can't extract the test expression from " + teststr); //get the text inside the quotes, i.e the expression String[] actualExpression = StringUtils.substringsBetween(teststr, "\"", "\""); if (actualExpression == null || actualExpression.length != 1 || StringUtils.isBlank(actualExpression[0])) { throw new BadFormDesignException("Can't extract the test expression from " + teststr);//throw bad design exception here } return actualExpression[0]; }
private String[] obtainKeywordsForAnEntityFromWikipedia(String entity){ yrunner.setKey("xdnRVcVf9m4vDvW1SkTAz5kS5DFYa19CrPYGelGJxnc"); List<HitBase> resultList = yrunner.runSearch(entity, 20); HitBase h = null; for (int i = 0; i < resultList.size(); i++) { h = resultList.get(i); if (h.getUrl().indexOf("wikipedia.")>-1) break; } String content = pFetcher.fetchOrigHTML(h.getUrl()); content = content.replace("\"><a href=\"#", "&_&_&_&"); String[] portions = StringUtils.substringsBetween(content, "&_&_&_&", "\"><span"); List<String> results = new ArrayList<String>(); for(int i = 0; i< portions.length; i++){ if (portions[i].indexOf("cite_note")>-1) continue; results.add(entity + " " + portions[i].replace('_', ' ').replace('.',' ')); } return results.toArray(new String[0]); }
public static String getPageNestedSubstrings(String surl, String outerStartTag, String outerEndTag, String innerStartTag, String innerEndTag, String cookie, String username, String password) throws IOException{ String page; if(cachedURLString == null || !surl.equalsIgnoreCase(cachedURLString)){ page = readPageIntoString(surl,cookie,username, password); cachedPage = page; cachedURLString = surl; } else{ page = cachedPage; } String outerSubstring = StringUtils.substringBetween(page, outerStartTag, outerEndTag); String[] innerSubstrings = StringUtils.substringsBetween(outerSubstring, innerStartTag, innerEndTag); String allStrings = ""; String DELIMITER = ","; if(innerSubstrings != null){ for(String substring: innerSubstrings){ allStrings = allStrings + StringUtils.trim(substring) + DELIMITER; } // remove last delimiter allStrings = StringUtils.removeEnd(allStrings, DELIMITER); } return allStrings; }
String[] results = StringUtils.substringsBetween(pageOrigHTML, "<CompleteSuggestion>", "</CompleteSuggestion>"); List<List<String>> accum = new ArrayList<List<String>>(); if (results==null)
private String getEmbedURL(JSONObject result) throws JSONException { final JSONObject richSnippet = result.optJSONObject("richSnippet"); if (richSnippet != null) { final JSONObject metatags = richSnippet.optJSONObject("metatags"); if (metatags != null) { final String pageId = metatags.optString("ajsPageId", null); if (StringUtils.isNumeric(pageId)) { final String[] hostnames = StringUtils.substringsBetween(result.getString("unescapedUrl"), "//", "/"); if (hostnames.length == 1) { return String.format("https://%s/plugins/servlet/remotepageview?pageId=%s", hostnames[0], pageId); } } } } return ""; }
String target = StringUtils.substringsBetween(req.getPathInfo(), clientEndpoint, "/observe")[0]; Registration registration = server.getRegistrationService().getByEndpoint(clientEndpoint); if (registration != null) {
String[] productFeatures = StringUtils.substringsBetween(pageOrigHTML, "<li>", "</li>" ); if (productFeatures!=null){ for(String item: productFeatures ){
String[] keys; if (StringUtils.contains(this.key, "[")) { String[] substringsBetween = StringUtils.substringsBetween(this.key, "[", "]"); keys = StringUtils.split(substringsBetween[0], ","); } else {