473,506 Members | 16,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

regular expressions

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
5 1465
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4155
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
2
4989
by: Sehboo | last post by:
Hi, I have several regular expressions that I need to run against documents. Is it possible to combine several expressions in one expression in Regex object. So that it is faster, or will I...
1
509
by: Sehboo | last post by:
Hi, I have several regular expressions that I need to run against documents. Is it possible to combine several expressions in one expression in Regex object. So that it is faster, or will I...
4
5141
by: Együd Csaba | last post by:
Hi All, I'd like to "compress" the following two filter expressions into one - assuming that it makes sense regarding query execution performance. .... where (adate LIKE "2004.01.10 __:30" or...
1
4362
by: Allan Ebdrup | last post by:
I have a dynamic list of regular expressions, the expressions don't change very often but they can change. And I have a single string that I want to match the regular expressions against and find...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.