Example usage for org.apache.commons.lang3 StringUtils substringBetween

List of usage examples for org.apache.commons.lang3 StringUtils substringBetween

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils substringBetween.

Prototype

public static String substringBetween(final String str, final String tag) 

Source Link

Document

Gets the String that is nested in between two instances of the same String.

A null input String returns null .

Usage

From source file:kenh.expl.functions.SubstringBetween.java

public String process(String str, String tag) {
    return StringUtils.substringBetween(str, tag);
}

From source file:com.ppcxy.cyfm.showcase.demos.utilities.string.ApacheStringUtilsDemo.java

@Test
public void substring() {
    String input = "hahakaka";
    String result = StringUtils.substringAfter(input, "ha");
    assertThat(result).isEqualTo("hakaka");

    result = StringUtils.substringAfterLast(input, "ha");
    assertThat(result).isEqualTo("kaka");

    assertThat(StringUtils.substringBetween("'haha'", "'")).isEqualTo("haha");
    assertThat(StringUtils.substringBetween("{haha}", "{", "}")).isEqualTo("haha");
}

From source file:com.norconex.commons.lang.time.YearMonthDay.java

/**
 * Constructs a YearMonthDay from a string of this format: 
 * <code>yyyy-MM-dd</code>./*from   w ww  .j  a va2s .c o  m*/
 * @param date a date string
 */
public YearMonthDay(String date) {
    this(Integer.valueOf(StringUtils.substringBefore(date, "-")),
            Integer.valueOf(StringUtils.substringBetween(date, "-")),
            Integer.valueOf(StringUtils.substringAfterLast(date, "-")));
}

From source file:de.hybris.platform.chinesepspalipaymockaddon.controllers.pages.AlipayMockController.java

@SuppressWarnings("boxing")
@RequestMapping(value = "", method = RequestMethod.GET)
public String doGetGateWay(final Model model, final HttpServletRequest request) {
    final Map<String, String[]> requestParamMap = request.getParameterMap();
    if (requestParamMap == null) {
        return AlipayMockControllerConstants.Pages.AlipayMockPage;
    }/*from   w  w w .  j  a  v  a  2  s. c om*/
    final String baseGateWay = request.getRequestURL().toString();
    model.addAttribute("baseGateWay", baseGateWay);

    final Map<String, String> clearParams = removeUselessValue(requestParamMap);
    this.setCSRFToken(clearParams, request);

    final String service = request.getParameter("service");
    if (service == null) {
        return AlipayMockControllerConstants.Pages.AlipayMockPage;
    }
    XSSFilterUtil.filter(service);
    final boolean signIsValid = isSignValid(clearParams);
    model.addAttribute("signIsValid", Boolean.valueOf(signIsValid));
    model.addAttribute("params", clearParams);
    model.addAttribute("out_trade_no", clearParams.get("out_trade_no"));
    model.addAttribute("total_fee", clearParams.get("total_fee"));
    model.addAttribute("storefront", (StringUtils.substringBetween(request.getContextPath(), "/")));

    if ("refund_fastpay_by_platform_pwd".equals(service)) {
        return AlipayMockControllerConstants.Pages.AlipayRefundPage;
    }

    return AlipayMockControllerConstants.Pages.AlipayMockPage;
}

From source file:de.hybris.platform.chinesepspalipaymockaddon.controllers.pages.AlipayMockController.java

@RequestMapping(value = "/refund", method = RequestMethod.GET)
public String view(final Model model, final HttpServletRequest request) {
    final Map<String, String[]> requestParamMap = request.getParameterMap();
    if (requestParamMap == null) {
        return AlipayMockControllerConstants.Pages.AlipayRefundTestPage;
    }//  w  w  w  . ja  va 2s .co m
    final String baseGateWay = request.getRequestURL().toString();
    model.addAttribute("baseGateWay", baseGateWay);

    model.addAttribute("storefront", (StringUtils.substringBetween(request.getContextPath(), "/")));

    final Map<String, String> clearParams = removeUselessValue(requestParamMap);
    setCSRFToken(clearParams, request);
    return AlipayMockControllerConstants.Pages.AlipayRefundTestPage;
}

From source file:net.sf.dynamicreports.examples.complex.applicationform.ApplicationFormDesign.java

private HorizontalListBuilder dateOfBirth(Date dateOfBirth) {
    String date = new SimpleDateFormat("MM/dd/yyyy").format(dateOfBirth);
    HorizontalListBuilder list = cmp.horizontalList().add(label("Date Of Birth", 5))
            .add(textCell(StringUtils.substringBefore(date, "/"), 2), label("/", 1, centeredStyle))
            .add(textCell(StringUtils.substringBetween(date, "/"), 2), label("/", 1, centeredStyle))
            .add(textCell(StringUtils.substringAfterLast(date, "/"), 4));
    return list;/*ww  w.j a  v a2s .c  om*/
}

From source file:info.magnolia.security.app.dialog.action.SaveUserDialogAction.java

private String resolveUserManagerRealm(final JcrNodeAdapter userItem) throws RepositoryException {
    String userPath = userItem.getJcrItem().getPath();
    if (userItem instanceof JcrNewNodeAdapter && !"/".equals(userPath)) {
        //parent JCR item is returned so we need enclose path with "/" to handle correctly in case when user is placed directly under realm root
        userPath += "/";
    }/*  w  w w. j  a v  a2 s.c  o  m*/
    return StringUtils.substringBetween(userPath, "/");
}

From source file:org.aliuge.crawler.extractor.selector.action.string.StringBetweenAction.java

/**
 * ??<br>/*from www  .  j ava 2  s.co m*/
 * tt,t<br>
 * t,xt,x<br>
 * t,x,#t,x#
 */
@Override
public String doAction(String content) {
    if (StringUtils.isNotBlank(content)) {
        String[] ss = StringUtils.split(exp, ",");
        if (ss.length == 1) {
            return StringUtils.substringBetween(content, ss[0]);
        } else if (ss.length == 2) {
            return StringUtils.substringBetween(content, ss[0], ss[1]);
        } else if (ss.length == 3) {
            String[] contents = StringUtils.substringsBetween(content, ss[0], ss[1]);
            if (null != contents) {
                StringBuilder sb = new StringBuilder();
                for (String s : contents) {
                    sb.append(s).append(ss[2]);
                }
                return sb.substring(0, sb.length() - 1);
            }
        } else {
            return content;
        }
    }
    return "";
}