shivam0101 Posted July 11, 2010 Share Posted July 11, 2010 Hello, $line = "01 This is a sentence COND This is another sentence 10 P This is final sentence"; preg_match('/\bCOND\b.*(\d+) P\b/', trim($line), $matches) print_r($matches[1]) prints 10 I want String "WR" in place of P. I changed WR with P without any luck. Can some one tell me what change has to be done? I also want to know what's the meaning of P\b/', mean? Thanks Link to comment https://forums.phpfreaks.com/topic/207456-preg-match-condition/ Share on other sites More sharing options...
Psycho Posted July 12, 2010 Share Posted July 12, 2010 I want String "WR" in place of P. What does that mean? Do you want to replace "P" with "WR" in the string or do you have a different string that uses "WR" insterad of "P" and you need the number in that string? I also want to know what's the meaning of P\b/', mean? The space and "P" is trying to match those characters. The "\b" matches a word boundry such as a space, tab, period, etc. The "/" is the closing delimited for the expression. Try giving a better explanation of what you are trying to achieve. Link to comment https://forums.phpfreaks.com/topic/207456-preg-match-condition/#findComment-1084673 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.