473,657 Members | 2,409 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_OR DER);

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 1472
Gandalf nous disait :
preg_match_all( "/hello.+yehuda/s", $data, $out, PREG_PATTERN_OR DER);
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...@dyno de.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_OR DER);
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_OR DER);

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...@dyno de.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_OR DER);
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_OR DER);

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
4167
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 regular expressions easier to create and use (and in my experience as a regular expression user, it makes them MUCH easier to create and use.) I'm still working on formal documentation, and in any case, such documentation isn't necessarily the...
2
5051
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 have to use all the expressions seperately? Here are my regular expressions that check for valid email address and link Dim Expression As String =
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 have to use all the expressions seperately? Here are my regular expressions that check for valid email address and link Dim Expression As String =
4
5167
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 adate LIKE "2004.01.10 __:15") .... into something like this: .... where adate LIKE "2004.01.10 __:(30/15)" ...
1
4376
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 the first regular expression that matches the string. I've gor the regular expressions ordered so that the highest priority is first (if two or more regular expressions match the string I want the first one returned) The code that does this has...
0
8395
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7330
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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 we have to send another system
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.