473,609 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble with ereg() and matching right bracket "]"

I'm trying to figure out what I'm doing wrong when using ereg().

This is my regexp:

ereg("^[\]]$", "]");

and that does'n work, but this does:

ereg("^[\[]$", "[");
How come I can match left bracket but not the right?
am I using the esc char correctly?

please help me.

regards
/gange
Jul 17 '05 #1
1 2343
ga***@elak.org (Stefan Gangefors) writes:
I'm trying to figure out what I'm doing wrong when using ereg().

This is my regexp:

ereg("^[\]]$", "]");

and that does'n work, but this does:

ereg("^[\[]$", "[");

How come I can match left bracket but not the right?
am I using the esc char correctly?


The "Regular Expression Functions (POSIX Extended)" chapter of the
PHP manual directs readers to the regex manual page in the PHP
source code. That manual page says:

"To include a literal `]' in the list, make it the first character
(following a possible `^'). To include a literal `-', make it the
first or last character, or the second end- point of a range. To
use a literal `-' as the first end- point of a range, enclose it
in `[.' and `.]' to make it a collating element (see below). With
the exception of these and some combinations using `[' (see next
paragraphs), all other special characters, including `\', lose their
special significance within a bracket expression."

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1636
by: Evgeny Gopengauz | last post by:
What is the way recommended by Microsoft for distributing the MSSQL database with end-user application if I don't like to use sql-scripts because I need to hide the stored procedures sources (they are marked as "encrypted")? Backup/restore? Or something else? *** Sent via Developersdex http://www.developersdex.com ***
1
1422
by: Edward King | last post by:
I have a statement in a asp,like follows£º var str=window.top.main.document.all.contenttext.value; I use IIS5.0 to deploy this asp,then I visit this asp like follows: http://localhost/test/default.asp I found I can get this page,then I use my computer's IP address, http://192.168.0.3/test/default.asp I got errors! It said "no right"£¬then I erase this statement,then I visit
6
12985
by: Dean Slindee | last post by:
I am looking for the "right" way to handle inserting and presenting null date values. Public Const c_NullDate As Date = #12:00:00 AM# If I set the value of a date variable in an SQL Server insert statement to c_NullDate, the insert statement works. When I re-read the row and display the inserted date value in a text box, the string "1/1/1900" is displayed. If one wanted the textbox to display an empty string, how should either the insert...
44
9423
by: Viken Karaguesian | last post by:
Hello all, On occasion I want to open hyperlinks (images, etc.) in a new window. In the past, I've used target="_blank" to open the link in a new window. However, using the "target" attribute causes my pages to fail validation (strict doctype). The validator says "There is no attribute 'target'.." So...how do I open a link in a new window, without Javscript, and pass strict validation?
1
8021
by: tshad | last post by:
I have columns with text and radio buttons that I would like to center or put to the right of the cell, but the attribute ItemStyle-HorizontalAlign="right" doesn't seem to work. <asp:TemplateColumn HeaderText="Job Board" Visible="true" ItemStyle-Width="150px" HeaderStyle-Width="150px" ItemStyle-VerticalAlign="middle" ItemStyle-HorizontalAlign="right"> <itemtemplate> asp:Label ID="JobBoardName" Text='<%#
4
1912
by: lionheart | last post by:
Hi, I am currently trying to group my classes using namespaces. But since these groups are not really independend I end up to have a lot of forward declarations. My first approache was to enclose all class definitions and forward declarations in the corresponding headers directly. Which turned out to make it difficult to read the header, and created a lot of overhead. Therefore at the moment I am using a headerfile dedicated to forward
5
3122
by: Terry Olsen | last post by:
This is the easiest way I can think of to do this: tmp=Right("0" & Now.Month.ToString, 2) The only way I've figured to do it the .NET way is this: tmp="0" & Now.Month.ToString tmp=tmp.substring(tmp.length-3) Surely, there's a more elegant way?
8
4614
by: Chaitanya | last post by:
Hello, In my Application i want to know when user clicks both the "Left" and "Right" buttons of the Mouse. I am getting a number like this "3145728". But the MouseButtons Enum contains only Left, Right, Middle, None, XButton1 and XButton2. I am using .NET 1.1 version. How can i convert "3145728" to MouseButtons Enum? why Mouse Left+Right click not added to the Enum? Can anyone help me?
8
36500
by: rssd | last post by:
can somebody help me. I'm trying to read some excel files but i'm always getting this error No type library matching "Microsoft Excel" found at D:\Genes_datasets\exp.pl line 4 Win32::OLE(0.16): GetOleTypeLibObject() Not a Win32::OLE::TypeLib object at C:/Perl/site/lib/Win32/OLE/Const.pm line 45. Died at D:\Genes_datasets\exp.pl line 6. i don't ve microsoft excel but open office installed, i think that could be a problem. But these...
0
8588
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...
0
8556
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8236
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
8410
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...
1
6068
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4037
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
4103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2541
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
1
1690
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.