1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Regex Help

Discussion in 'XenForo Development Discussions' started by Brent W, Aug 27, 2013.

  1. Brent W

    Brent W Well-Known Member

    I want to find everything between a ^ and a / and then hold that in a variable to use elsewhere. Anyone throw me the expression for that?
  2. Chris D

    Chris D XenForo Developer Staff Member

    The expression would look like this:

    The match between the ^ and / would be available in $1.

    Example in PHP:

            $haystack '^Here is the needle/';
    $needle preg_replace('/\^(.*?)\//is'"The Found Text is: $1"$haystack);
    echo $needle will produce: "The Found Text is: Here is the needle"
    Brent W likes this.

Share This Page