I have the following code (I need to extract everything between
slash):
$buff="0,x,R / 1,y,R / - / 1,y,R";
preg_match_all("/\s*([0-9]\s*,\s*[a-z]\s*,\s*.\s*)\s*[\/]\s*|\s*(-)\s*[\/]/U",$buff,$izlaz);
var_dump($izlaz);
This outputs:
array(3) {
[0]=>
array(4) {
[0]=>
string(7) "0,x,R /"
[1]=>
string(8) " 1,y,R /"
[2]=>
string(4) " - /"
[3]=>
string(8) " 1,y,R"
}
[1]=>
array(4) {
[0]=>
string(5) "0,x,R"
[1]=>
string(5) "1,y,R"
[2]=>
string(0) ""
[3]=>
string(5) "1,y,R"
}
[2]=>
array(4) {
[0]=>
string(0) ""
[1]=>
string(0) ""
[2]=>
string(1) "-"
[3]=>
string(0) ""
}
}
Problem is in the 3rd row: why is it there? I would expect '-' sign in
2nd row... 2 1399
On Tue, 18 Jan 2005 22:20:09 +0100, Josip <nj*****@gmail.com> wrote: I have the following code (I need to extract everything between slash):
$buff="0,x,R / 1,y,R / - / 1,y,R";
preg_match_all("/\s*([0-9]\s*,\s*[a-z]\s*,\s*.\s*)\s*[\/]\s*|\s*(-)\s*[\/]/U",$buff,$izlaz);
Hm, this is partial solution...
preg_match_all("/(\s*[0-9]\s*,\s*[a-z]\s*,\s*[LR]\s*\s*|\s*[\-]\s*)[\/]\s*/U",$buff,$izlaz);
Josip wrote: I have the following code (I need to extract everything between slash):
$buff="0,x,R / 1,y,R / - / 1,y,R";
preg_match_all("/\s*([0-9]\s*,\s*[a-z]\s*,\s*.\s*)\s*[\/]\s*|\s*(-)\s*[\/]/U",$buff,$izlaz);
Is that really your pattern? I only ask because the output
below doesn't come from that.
var_dump($izlaz);
This outputs:
array(3) { [0]=> array(4) {
No it doesn't. There are only three matches to the full
pattern in your subject string.
[0]=> string(7) "0,x,R /" [1]=> string(8) " 1,y,R /" [2]=> string(4) " - /" [3]=> string(8) " 1,y,R"
The last string here doesn't match because there must be a
slash at the end. You should allow the last slash to be
optional in your pattern. Consider:
`(\d\s*,\s*[a-z]\s*,\s*.|-)\s*/?`
[ ... ]
Problem is in the 3rd row: why is it there? I would expect '-' sign in 2nd row...
Your subject string is '0,x,R / 1,y,R / - / 1,y,R'. The
hyphen is in the third segment, not the second. Move the
hyphen to the second segment and watch what happens.
--
Jock This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Frank Passek |
last post by:
Dear all,
I've encountered some strange behaviour with PHP (4.3.2) using the CLI-API.
When I provide an option in the first line of my script like so:
#!/usr/bin/php -c /path_to_my_ini_file
and...
|
by: Paul Drummond |
last post by:
Hi all,
I am developing software for Linux Redhat9 and I have noticed some very
strange behaviour when throwing exceptions within a shared library.
All our exceptions are derived from...
|
by: Bruno van Dooren |
last post by:
Hi All,
i have some (3) different weird pointer problems that have me stumped. i
suspect that the compiler behavior is correct because gcc shows the same
results.
...
|
by: Sebastian C. |
last post by:
Hello everybody
Since I upgraded my Office XP Professional to SP3 I got strange
behaviour.
Pieces of code which works for 3 years now are suddenly stop to work
properly.
I have Office XP...
|
by: Edd Dawson |
last post by:
Hi. I have a strange problem involving the passing of command line
arguments to a C program I'm writing. I tried posting this in
comp.programming yesterday but someone kindly suggested that I'd...
|
by: DeltaOne |
last post by:
#include<stdio.h>
typedef struct test{
int i;
int j;
}test;
main(){
test var;
var.i=10;
var.j=20;
|
by: matevzb |
last post by:
I've ran into some fishy code that, at first glance, is buggy, but it
seems to work correctly
and none of the compilers I've tried (five so far, on various systems)
gives any warnings.
The code:...
|
by: Gotch |
last post by:
Hi,
I'm getting a very strange behaviour while running a project I've
done.... Let's expose it: I've two projects. Both of them use a Form
to do some Gui stuff. Other threads pack up messages...
|
by: Daniel Kraft |
last post by:
Hi,
I did encounter a strange problem in my C program, and traced it down;
it looks like I get different results for bit left shifts when the bit
count is a constant or a funtion-return value.
...
|
by: Dox33 |
last post by:
I ran into a very strange behaviour of raw_input().
I hope somebody can tell me how to fix this.
(Or is this a problem in the python source?)
I will explain the problem by using 3 examples....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
| |