Java Code Examples for org.apache.commons.lang3.RegExUtils#replaceAll()
The following examples show how to use
org.apache.commons.lang3.RegExUtils#replaceAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TappedOutDeckSniffer.java From MtgDesktopCompanion with GNU General Public License v3.0 | 5 votes |
public List<RetrievableDeck> getDeckList() throws IOException { if(httpclient==null) initConnexion(); String tappedJson = RegExUtils.replaceAll(getString(URL_JSON), "%FORMAT%", getString(FORMAT)); logger.debug("sniff url : " + tappedJson); String responseBody = httpclient.doGet(tappedJson); JsonElement root = URLTools.toJson(responseBody); List<RetrievableDeck> list = new ArrayList<>(); for (int i = 0; i < root.getAsJsonArray().size(); i++) { JsonObject obj = root.getAsJsonArray().get(i).getAsJsonObject(); RetrievableDeck deck = new RetrievableDeck(); deck.setName(obj.get("name").getAsString()); try { URI u = new URI(obj.get("resource_uri").getAsString()); deck.setUrl(u); } catch (URISyntaxException e) { deck.setUrl(null); } deck.setAuthor(obj.get("user").getAsString()); deck.setColor(""); list.add(deck); } return list; }
Example 2
Source File: StringReplaceAndRemoveUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void givenTestStrings_whenReplaceExactWordUsingRegExUtilsMethod_thenProcessedString() { String sentence = "A car is not the same as a carriage, and some planes can carry cars inside them!"; String regexTarget = "\\bcar\\b"; String exactWordReplaced = RegExUtils.replaceAll(sentence, regexTarget, "truck"); assertTrue("A truck is not the same as a carriage, and some planes can carry cars inside them!".equals(exactWordReplaced)); }
Example 3
Source File: JobResolverServiceImpl.java From genie with Apache License 2.0 | 5 votes |
/** * Helper to convert a set of tags into a string that is a suitable value for a shell environment variable. * Adds double quotes as necessary (i.e. in case of spaces, newlines), performs escaping of in-tag quotes. * Input tags are sorted to produce a deterministic output value. * * @param tags a set of tags or null * @return a CSV string */ private String tagsToString(final Set<String> tags) { final List<String> sortedTags = Lists.newArrayList(tags); // Sort tags for the sake of determinism (e.g., tests) sortedTags.sort(Comparator.naturalOrder()); final String joinedString = StringUtils.join(sortedTags, ','); // Escape quotes return RegExUtils.replaceAll(RegExUtils.replaceAll(joinedString, "'", "\\'"), "\"", "\\\""); }
Example 4
Source File: InitialSetupTask.java From genie with Apache License 2.0 | 5 votes |
/** * Helper to convert a set of tags into a string that is a suitable value for a shell environment variable. * Adds double quotes as necessary (i.e. in case of spaces, newlines), performs escaping of in-tag quotes. * Input tags are sorted to produce a deterministic output value. * * @param tags a set of tags or null * @return a CSV string */ @VisibleForTesting String tagsToString(final Set<String> tags) { final ArrayList<String> sortedTags = new ArrayList<>(tags == null ? Collections.emptySet() : tags); // Sort tags for the sake of determinism (e.g., tests) sortedTags.sort(Comparator.naturalOrder()); final String joinedString = StringUtils.join(sortedTags, ','); // Escape quotes return RegExUtils.replaceAll(RegExUtils.replaceAll(joinedString, "\'", "\\\'"), "\"", "\\\""); }
Example 5
Source File: ScooldUtils.java From scoold with Apache License 2.0 | 4 votes |
public String getSpaceName(String space) { if (DEFAULT_SPACE.equalsIgnoreCase(space)) { return ""; } return RegExUtils.replaceAll(space, "^scooldspace:[^:]+:", ""); }
Example 6
Source File: AetherhubDeckSniffer.java From MtgDesktopCompanion with GNU General Public License v3.0 | 4 votes |
@Override public MagicDeck getDeck(RetrievableDeck info) throws IOException { String uri="https://aetherhub.com/Deck/FetchDeckExport?deckId="+info.getUrl().getQuery().replace("id=",""); Document d =URLTools.extractHtml(info.getUrl().toURL()); String data = URLTools.extractAsString(uri); MagicDeck deck = new MagicDeck(); deck.setName(info.getName()); deck.setDescription(d.select("div.decknotes").text()); boolean sideboard=false; data = RegExUtils.replaceAll(data,"\\\\r\\\\n","\n"); data = RegExUtils.replaceAll(data,"\"",""); System.out.println(data); String[] lines = data.split("\n"); for(int i=0;i<lines.length;i++) { String line=lines[i].trim(); if(line.startsWith("Sideboard") || line.startsWith("Maybeboard")) { sideboard=true; } else if(!StringUtils.isBlank(line) && !line.equals("Deck")) { SimpleEntry<String, Integer> entry = parseString(line); try { MagicCard mc = MTGControler.getInstance().getEnabled(MTGCardsProvider.class).searchCardByName(entry.getKey(), null, true).get(0); notify(mc); if(sideboard) deck.getSideBoard().put(mc, entry.getValue()); else deck.getMain().put(mc, entry.getValue()); } catch(Exception e) { logger.error("couldn't not find " + entry.getKey()); } } } return deck; }
Example 7
Source File: MTGoldFishDashBoard.java From MtgDesktopCompanion with GNU General Public License v3.0 | 4 votes |
public HistoryPrice<MagicCard> getOnlinePricesVariation(MagicCard mc, MagicEdition me) throws IOException { String url = ""; HistoryPrice<MagicCard> historyPrice = new HistoryPrice<>(mc); historyPrice.setCurrency(getCurrency()); if(mc==null && me==null) return historyPrice; if (mc == null) { url = getString(URL_EDITIONS) + replace(me.getId(), false) + "#" + getString(FORMAT); } else { if (me == null) me = mc.getCurrentSet(); String cardName = RegExUtils.replaceAll(mc.getName(), " ", "+"); cardName = RegExUtils.replaceAll(cardName, "'", ""); cardName = RegExUtils.replaceAll(cardName, ",", ""); cardName = RegExUtils.replaceAll(cardName, "-", "+"); if (cardName.indexOf('/') > -1) cardName = cardName.substring(0, cardName.indexOf('/')).trim(); String editionName = RegExUtils.replaceAll(me.toString(), " ", "+"); editionName = RegExUtils.replaceAll(editionName, "'", ""); editionName = RegExUtils.replaceAll(editionName, ",", ""); editionName = RegExUtils.replaceAll(editionName, ":", ""); String foil=""; if(me.isFoilOnly()) foil=":Foil"; url = getString(WEBSITE) + "/price/" + convert(editionName) + foil+"/" + cardName + "#" + getString(FORMAT); } try { Document d = URLTools.extractHtml(url); parsing(d,historyPrice); return historyPrice; } catch (Exception e) { logger.error(e); return historyPrice; } }
Example 8
Source File: Crypto.java From mangooio with Apache License 2.0 | 4 votes |
public String getSizedSecret(String secret) { Objects.requireNonNull(secret, Required.SECRET.toString()); String key = RegExUtils.replaceAll(secret, "[^\\x00-\\x7F]", ""); return key.length() < MAX_KEY_LENGTH ? key : key.substring(KEYINDEX_START, MAX_KEY_LENGTH); }
Example 9
Source File: GitHubPushPayload.java From gocd with Apache License 2.0 | 4 votes |
@Override public String getBranch() { return RegExUtils.replaceAll(ref, "refs/heads/", ""); }
Example 10
Source File: GitLabPushPayload.java From gocd with Apache License 2.0 | 4 votes |
@Override public String getBranch() { return RegExUtils.replaceAll(ref, "refs/heads/", ""); }
Example 11
Source File: MTGStockDashBoard.java From MtgDesktopCompanion with GNU General Public License v3.0 | 3 votes |
@Override public HistoryPrice<MagicCard> getOnlinePricesVariation(MagicCard mc, MagicEdition me) throws IOException { if(mc==null) { logger.error("couldn't calculate edition only"); return new HistoryPrice<>(mc); } connect(); Integer id = mc.getMtgstocksId(); if(id==null) { int setId = -1; if (me != null) setId = correspondance.get(me.getId()); else setId = correspondance.get(mc.getCurrentSet().getId()); String url = MTGSTOCK_API_URI + "/search/autocomplete/" + RegExUtils.replaceAll(mc.getName(), " ", "%20"); logger.debug("get prices to " + url); JsonArray arr = URLTools.extractJson(url).getAsJsonArray(); id = arr.get(0).getAsJsonObject().get("id").getAsInt(); logger.trace("found " + id + " for " + mc.getName()); id = searchId(id, setId,URLTools.extractJson(MTGSTOCK_API_URI + "/prints/" + id).getAsJsonObject()); } return extractPrice(URLTools.extractJson(MTGSTOCK_API_URI + "/prints/" + id + "/prices").getAsJsonObject(), mc); }
Example 12
Source File: GenUtils.java From RuoYi-Vue with MIT License | 2 votes |
/** * 关键字替换 * * @param name 需要被替换的名字 * @return 替换后的名字 */ public static String replaceText(String text) { return RegExUtils.replaceAll(text, "(?:表|若依)", ""); }