Brent W Well-known member Aug 27, 2013 #1 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?
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?
Chris D XenForo developer Staff member Aug 28, 2013 #2 The expression would look like this: PHP: /\^(.*?)\//is The match between the ^ and / would be available in $1. Example in PHP: PHP: $haystack = '^Here is the needle/'; $needle = preg_replace('/\^(.*?)\//is', "The Found Text is: $1", $haystack); echo $needle; echo $needle will produce: "The Found Text is: Here is the needle"
The expression would look like this: PHP: /\^(.*?)\//is The match between the ^ and / would be available in $1. Example in PHP: PHP: $haystack = '^Here is the needle/'; $needle = preg_replace('/\^(.*?)\//is', "The Found Text is: $1", $haystack); echo $needle; echo $needle will produce: "The Found Text is: Here is the needle"