0

I have the string with parameters like

"Hello, %{user}. Please, give %{client} a knife".

So, please, I'm not familiar with regular expressions, and I need to have php construction which can get list of parameters from a string. Please, help me, I hope you can. Thank you.

1
  • 1
    Will you have to depend on someone else every time you need to maintain your own code too? This regular expression is quite simple. Give it a shot yourself and ask a question if you have specific problems. Commented Jun 26, 2012 at 10:22

1 Answer 1

1
$str = "Hello, %{user}. Please, give %{client} a knife".
preg_match_all("/%\{(.*?)\}/", $str, $matches);
print_r($matches);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.