-2

Possible Duplicate:
RegEx How to find text between two strings

I am new to REGEX and learning..this is emergency and some one need to help me, how can i get a value 6Lf4 (dynamic value) ,

 private="key" value="6Lf4" sent="yut"

P.s there are lots of attribitute named "Value" in an string, so i need some regex to find string between ="key" value=" , and "

Community
  • 1
  • 1
Neenu Jino
  • 17
  • 1
  • 3

1 Answers1

0

This should work given a strict format:

$matches = array();
preg_match_all('/="key" value="([^"]*)"/', $inputString, $matches);

This tests specifically for the given format with no exceptions. If there is a variable amount of whitespace between "key" and value, you can change the regex to have key"\s+value instead.

newfurniturey
  • 37,556
  • 9
  • 94
  • 102