FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP Regex





Ironz
hey,

i have a regular expression which is written in C# and want to transform it to php:

Code:
pattern = @"(?<1>.*?)\#(?<2>.*?)\#(?<3>.*?)\*";
Match NameMatch = Regex.Match(source,pattern);

the source i wanna match is something like this:

source = "First#Second#12,345*Ano-ther#Also_another#45,678,548*";

it should return:
1: First
2: Second
3: 12,345

and another match:
1: Ano-ther
2: Also_another
3: 45,678,548


i've searched several places but i couldn't make an equivalent for that expression in php, i'm looking to get the same results (several matches with groups inside each match).

Can someone plz help me out with this?
Nyizsa
So you need to get substrings from a string using a predefined delimiter. I think you need the explode() function, and don't need a regex at all. Try something like the following:
Code:
$sections=explode('*',source);
$values=explode('#',$sections[n]);

So you can select which value of which section is to be printed.
I hope it helps!
Related topics
http://tuvanonline.com/library/index.php
PHP-Nuke platium?
PHP Write to line
Anyone good with PHP-NUKE?
PHP safety?
req: PHP to list files in directory, and link to them
php admin and mysql admin console
Mysql And PHP HELP PLZ
Great php editor
Script php about gallery
PHP DB Error: syntax error
erm? what are these?
programming Language to learn
using <? instead of <?php (solved)
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.