Re: Silly regex giveing me a hard time
| From: | Darvin | Date: | Sun, 16 Oct 2005 19:21:30 +0000 |
| Subject: | Re: Silly regex giveing me a hard time | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-224205@lists.php.net to get a copy of this message | ||
Dotan Cohen wrote:
I have a list like this: 235 Some infoTry preg_replace("/^[ ]*[0-9]+[ ]*/", "", $data); It means: from the beginning of $data looks for space (if any), then almost one number followed by space (if any). If you don't use ^ you may remove the number 5 'from other 5 things' Darvin12323 other 5 thingsNo number on this line! 43 something or other I need to remove the first number from each line, so that I will get this: Some info other 5 things No number on this line! something or other So I tried: $data=preg_replace("//n[ ]*[0-9][ ]*/", "", $data); That is (I think): any amount of spaces, followed by any number, followed by any amount of spaces. This doesn't seem to be the way to do it. Anybody have a better idea? Thanks. Dotan http://technology-sleuth.com