Connecting Tech Pros Worldwide Forums | Help | Site Map

regular expressions

Gandalf
Guest
 
Posts: n/a
#1: Aug 16 '08
OK i have for example this string "hello my name is : yehuda hello my
brother name is yehuda"

Now I would like to split it in to array

so if I'll just use this:

preg_match_all("/hello.+yehuda/s", $data, $out, PREG_PATTERN_ORDER);

the function will use only the last yehuda as my splitter and keep the
string/

so how do i express string which shouldn't contain other string?



thanks




Nicolas Bouthors
Guest
 
Posts: n/a
#2: Aug 16 '08

re: regular expressions


Gandalf nous disait :
Quote:
preg_match_all("/hello.+yehuda/s", $data, $out, PREG_PATTERN_ORDER);
so how do i express string which shouldn't contain other string?
Try to limit the action of your + with +? like this : /hello.+?yehuda/


--
Nicolas - 06 20 71 62 34 - http://nicolas.bouthors.org/album/
Gandalf
Guest
 
Posts: n/a
#3: Aug 17 '08

re: regular expressions


On Aug 17, 4:09*am, Russell Wood <bitbuc...@dynode.netwrote:
Quote:
On 2008-08-16, Gandalf <goldn...@gmail.comwrote:
>
Quote:
OK i have for example this string "hello my name is : yehuda hello my
brother name is yehuda"
>
Quote:
Now I would like to split it in to array
>
Quote:
so if I'll just use this:
>
Quote:
preg_match_all("/hello.+yehuda/s", $data, $out, PREG_PATTERN_ORDER);
>
Quote:
the function will use only the last yehuda as my splitter and keep the
string/
>
Quote:
so how do i express string which shouldn't contain other string?
>
If you want to split the string into an array at each space then use
`explode':
>
* * * *http://au.php.net/manual/en/function.explode.php
>
--
Russell Wood
<http://www.dynode.net/~rjw/>
ye I know explode but this is only an example my real code function
need regular expression
so is their something I can write instead of "." so a specific string
wont be include?

thanks!

Russell Wood
Guest
 
Posts: n/a
#4: Aug 17 '08

re: regular expressions


On 2008-08-16, Gandalf <goldnery@gmail.comwrote:
Quote:
OK i have for example this string "hello my name is : yehuda hello my
brother name is yehuda"
>
Now I would like to split it in to array
>
so if I'll just use this:
>
preg_match_all("/hello.+yehuda/s", $data, $out, PREG_PATTERN_ORDER);
>
the function will use only the last yehuda as my splitter and keep the
string/
>
so how do i express string which shouldn't contain other string?
If you want to split the string into an array at each space then use
`explode':

http://au.php.net/manual/en/function.explode.php

--
Russell Wood
<http://www.dynode.net/~rjw/>
dmf
Guest
 
Posts: n/a
#5: Aug 17 '08

re: regular expressions


On Aug 16, 10:31*pm, Gandalf <goldn...@gmail.comwrote:
Quote:
On Aug 17, 4:09*am, Russell Wood <bitbuc...@dynode.netwrote:
>
>
>
Quote:
On 2008-08-16, Gandalf <goldn...@gmail.comwrote:
>
Quote:
Quote:
OK i have for example this string "hello my name is : yehuda hello my
brother name is yehuda"
>
Quote:
Quote:
Now I would like to split it in to array
>
Quote:
Quote:
so if I'll just use this:
>
Quote:
Quote:
preg_match_all("/hello.+yehuda/s", $data, $out, PREG_PATTERN_ORDER);
>
Quote:
Quote:
the function will use only the last yehuda as my splitter and keep the
string/
>
Quote:
Quote:
so how do i express string which shouldn't contain other string?
>
Quote:
If you want to split the string into an array at each space then use
`explode':
>>
Quote:
--
Russell Wood
<http://www.dynode.net/~rjw/>
>
ye I know explode but this is only an example my real code function
need regular expression
so is their something I can write instead of "." so a specific string
wont be include?
>
thanks!
You may want to take a look at http://www.troubleshooters.com/codec...rl/perlreg.htm.
It should give you a better understanding of regex's. You should find
your answer here.
Curtis
Guest
 
Posts: n/a
#6: Aug 17 '08

re: regular expressions


Gandalf wrote:
Quote:
OK i have for example this string "hello my name is : yehuda hello my
brother name is yehuda"
>
Now I would like to split it in to array
>
so if I'll just use this:
>
preg_match_all("/hello.+yehuda/s", $data, $out, PREG_PATTERN_ORDER);
>
the function will use only the last yehuda as my splitter and keep the
string/
>
so how do i express string which shouldn't contain other string?
>
>
>
thanks
>
>
>
I'm not sure I understand what you're trying to do, exactly. It sounds
like you might want preg_split, though. If you could post an example
of what you do want, it might help.

--
Curtis
Closed Thread