I have a text file like with entries like this
10692336 217] albafghffg@hotmail.com:0943689
I need to fine these entries 1 per line from a text file and delte everything to the left side of
]
delete characters?
Moderator: General Moderators
- christian_phpbeginner
- Forum Contributor
- Posts: 136
- Joined: Sat Jun 03, 2006 2:43 pm
- Location: Java
Re: delete characters?
hi, I wonder if you have found the solution yet. But, what a coincedence, your case is just mine also.jasondavis wrote:I have a text file like with entries like this
10692336 217] albafghffg@hotmail.com:0943689
I need to fine these entries 1 per line from a text file and delte everything to the left side of
]
So, I have the code:
Code: Select all
$strTest = "10692336 217] albafghffg@hotmail.com:0943689";
//pay attention on these 2 different patterns in order to do something else different but using the same $strTest
$patternStrTest = '/(\d+\s\d+)\W/';
$patternRetrieveFrontNumber= '/\][a-z\s\@\.\w\:]+/';
preg_match_all($patternStrTest, $strTest, $arrayTest);
foreach($arrayTest as $line) {
//Output A
echo "<pre>";
print_r ($line);
echo "</pre>";
}
$deleteNum= preg_replace ($patternStrTest, '', $strTest);
//Output B
echo $deleteNum;
$deleteEmail = preg_replace ($patternRetrieveFrontNumber, '', $strTest);
//Output C
echo $deleteEmail;Output A:
Code: Select all
Array
(
[0] => 10692336 217]
)
Array
(
[0] => 10692336 217
)Code: Select all
albafghffg@hotmail.com:0943689Code: Select all
10692336 217Good luck,
Chris