By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,664 Members | 1,669 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,664 IT Pros & Developers. It's quick & easy.

regular expressions

P: n/a
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

Aug 16 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Gandalf nous disait :
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/
Aug 16 '08 #2

P: n/a
On Aug 17, 4:09*am, Russell Wood <bitbuc...@dynode.netwrote:
On 2008-08-16, Gandalf <goldn...@gmail.comwrote:
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/>
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!

Aug 17 '08 #3

P: n/a
On 2008-08-16, Gandalf <go******@gmail.comwrote:
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/>
Aug 17 '08 #4

P: n/a
dmf
On Aug 16, 10:31*pm, Gandalf <goldn...@gmail.comwrote:
On Aug 17, 4:09*am, Russell Wood <bitbuc...@dynode.netwrote:
On 2008-08-16, Gandalf <goldn...@gmail.comwrote:
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/>

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.
Aug 17 '08 #5

P: n/a
Gandalf wrote:
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
Aug 17 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.