Hello:
Using PHP 4.3.11
The line: $strDate = preg_split('/[\.\/-]/', $my_date);
works to break apart a date in the form mm/dd/yyyy or mm.dd.yyyy or
mm-dd-yyyy
but the line: $strDate = preg_split('/[\/-\.]/', $my_date);
doesn't work.
Why does the order of the items make a difference?
Thanks,
Ken 3 2351
"none" <""krwl\"@(none)"> wrote in message
news:ML********************@rcn.net... Hello:
Using PHP 4.3.11
The line: $strDate = preg_split('/[\.\/-]/', $my_date); works to break apart a date in the form mm/dd/yyyy or mm.dd.yyyy or mm-dd-yyyy but the line: $strDate = preg_split('/[\/-\.]/', $my_date); doesn't work.
Why does the order of the items make a difference?
In a regular expression character class definition (the bit in the []s), a
hyphen denotes a range of characters, so [a-z] will match all lowercase
letters of the alphabet, and [0-9] will match all numbers from 0 to 9. If
you escape your hyphen, it doesn't matter where you put it in your class.
$strDate = preg_split('/[\/\-\.]/', $my_date);
Thanks,
Ken
hope that helps!
dave
"d" <d@example.com> wrote: In a regular expression character class definition (the bit in the []s), a hyphen denotes a range of characters, so [a-z] will match all lowercase letters of the alphabet, and [0-9] will match all numbers from 0 to 9. If you escape your hyphen, it doesn't matter where you put it in your class.
$strDate = preg_split('/[\/\-\.]/', $my_date);
Absolutely right. Also, this is rather trivial, but you shouldn't need to
escape the . in a character class, it's only a token when used outside a
character class. When inside a character class, the dot as well as
quantifiers (like *, ? etc.) are interpreted as literals.
Allen
Al13n wrote: In a regular expression character class definition (the bit in the []s), a hyphen denotes a range of characters, so [a-z] will match all lowercase letters of the alphabet, and [0-9] will match all numbers from 0 to 9. If you escape your hyphen, it doesn't matter where you put it in your class.
$strDate = preg_split('/[\/\-\.]/', $my_date); Absolutely right. Also, this is rather trivial, but you shouldn't need to escape the . in a character class, it's only a token when used outside a character class. When inside a character class, the dot as well as quantifiers (like *, ? etc.) are interpreted as literals.
Allen and Dave:
Thanks very much for your help. I'm surprised that /[\.\/-]/ worked at
all! A better way to have written it would have been: #[./\-]# which
works great.
Thanks, again.
Ken This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Peter |
last post by:
L.S.
I am trying to cut a string into substrings. The string at hand looks
something like this:
$data='one|two|three|four\nfive|six|seven|eight'; //observe the chr(10) in
the middle
I...
|
by: Sims |
last post by:
Hi,
I need some help to split data using regular expression
Consider the string
'1,2,3', I can split it using, preg_split("/,/", '1,2,3') and i correctly
get =1, =2,=3.
Now if i have
|
by: voipcanada |
last post by:
is there any thing we can write to keep the right txt to the = sign in
the preg_split. from the following lines
DST-NUMBER-IN=0033512877596, DST-NUMBER-OUT=98751#33512877596,...
|
by: der |
last post by:
Hello all,
I've a question about order of evaluations in expressions that have && and
|| operators in them.
The question is: will the evalution go left-to-right, no matter what -- even
if the...
|
by: mdh |
last post by:
May I ask the group the following: (Again, alas , from K&R)
This is part of a function:
while ( ( array1 = array2 ) != '\0' ); /* etc etc */
Is this the order that this is evaluated?
...
|
by: chadsmith76 |
last post by:
hello,
I have listings with coordinates, i would like to do ORDER BY and
display listings with coords first. If they don't have coords the value
is blank and the coords go both positive and...
|
by: tiggman |
last post by:
Why preg_split works only if the char # before the delimiter is 21 or less?
example php code:
=============
$right = "{Hello Im very aaaaaa {cool|not cool}}";
print $right."<br>";
$pattern =...
|
by: Jeroen |
last post by:
Hi all,
I've got a very specific question about the evaluation order in C++.
Assume some kind of custom array class, with an overloaded subscript
operator. In the following code:
{
my_array...
|
by: mark1491 |
last post by:
I am trying to split a string into sentences with preg_split, but I would like it to not split initials.
Examples:
Mark H. Doolittle is my name. What is yours. ( I don't want it to split the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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,...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |