Home > Archive > PHP Language > February 2005 > php regular expression
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
php regular expression
|
|
|
| i have a script wrote in perl which i am looking to convert into php. I
have the regular expression
$field =~ s/^,//;
This is to remove a ',' at the start of a string. Does anyonw know what the
equivalent would be in php?? If i use this regualr expression in my php i
get the error
"parse error, unexpected '^'"
Thanks and regards
| |
| Oli Filth 2005-02-22, 3:57 pm |
| Sokar wrote:
> i have a script wrote in perl which i am looking to convert into php. I
> have the regular expression
>
> $field =~ s/^,//;
>
> This is to remove a ',' at the start of a string. Does anyonw know what the
> equivalent would be in php?? If i use this regualr expression in my php i
> get the error
>
> "parse error, unexpected '^'"
>
$field = preg_replace("/^,/", "", $field);
(Not tested)
--
Oli
| |
| Michael Fesser 2005-02-22, 3:57 pm |
| .oO("Sokar" <jmccloughlin@[remove this]hotmail.com> )
>i have a script wrote in perl which i am looking to convert into php. I
>have the regular expression
>
>$field =~ s/^,//;
>
>This is to remove a ',' at the start of a string. Does anyonw know what the
>equivalent would be in php??
Not equivalent, but probably faster:
$field = ltrim($field, ',');
It will remove _all_ ',' from the beginning of the string.
Micha
| |
|
| Thanks very much that worked great!!!!!!!!
"Michael Fesser" <netizen@gmx.net> wrote in message
news:lrfm11tg9k17is9jjdcum7qmj51ctldbgl@
4ax.com...
> .oO("Sokar" <jmccloughlin@[remove this]hotmail.com> )
>
the[color=darkred]
>
> Not equivalent, but probably faster:
>
> $field = ltrim($field, ',');
>
> It will remove _all_ ',' from the beginning of the string.
>
> Micha
|
|
|
|
|