PHP regular expressions

DKSV

New Member
I am trying to search for some pattern in PHP with the help of preg_match. Search pattern is like this (but this is wrong):\[code\] /[\d\s*-\s*\d\s*(usd|eur)]{1}/i\d starts with integer,\s* there can be any number of whitespaces,- there must be exactly one minus sign\s* there can be any number of whitespaces,\d then must be integer\s* there can be any number of whitespaces,(usd|eur) any of the following words must be present but one[\d\s*-\s*\d\s*(usd|eur)]{1} - in string there should be exactly one occurence\[/code\]above pattern does not work, where I am doing wrong? For testing:\[code\]<?php $pattern = '/[\d\s*-\s*\d\s*(usd|eur)]{1}/i'; $query = '100-120 100-120'; echo $pattern.'<br/>'; echo $query.'<br/>'; if(preg_match($pattern, $query)) echo 'OK'; else echo 'not OK!';?>\[/code\]Note:I am trying to extract patterns like this:\[code\]The price of item is 100 - 120 usd in our market\[/code\]
 
Top