I have the following php program
<?php
$pattern = "/.*PURCHASE.*?\d{2}\w{3}\s(.*)Ref:.*/";
$description = "PURCHASE Card no.: XXXXXXXXXXXXXXXX 13MAR IDEAMONEY MUMBAI Ref: 031352203423 ";
if(preg_match($pattern,$description,$matches))
{
print_r($matches);
}
?>
this is giving the exact output as
Array ( [0] => PURCHASE Card no.: 5497XXXXXXXX1502 13MAR IDEAMONEY MUMBAI Ref: 031352203423 [1] => IDEAMONEY MUMBAI )
but the problem is when i save the contents of $description in mysql DB and fetch the same and perform the pattern matching its failing to match.
my new code looks like this
<?php
$pattern = "/.*PURCHASE.*?\d{2}\w{3}\s(.*)Ref:.*/";
include 'dbconnection.php';
$conn = get_dbConnection();
$query1 = "select * from MY_TABLE_NAME";
$stmt = $conn->query($query1);
while($result=$stmt->fetch())
{
$description = $result['MY_COLUMN_NAME'];
if(preg_match($pattern,$description,$matches))
{
print_r($matches);
}
?>
it is taking the same description content from database but its not matching.
If i replace the above $pattern by
$pattern = "/.*/";
it is giving the output as
Array ( [0] => PURCHASE Card no.: 5497XXXXXXXX1502 13MAR IDEAMONEY )
instead of giving
Array ( [0] => PURCHASE Card no.: XXXXXXXXXXXXXXXX 13MAR IDEAMONEY MUMBAI Ref: 031352203423 )
so the problem why the matching is not happening is it is neglecting the text after IDEAMONEY by itself.
how to resolve this?????