473,465 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get between square brackets

150 New Member
Expand|Select|Wrap|Line Numbers
  1. $special_chr = '\w\~\`\!\@\#\$\%\^\&\*\(\)\_\-\+\=\\\{\}\¦\:\;\"\'\?\/\>\.\<\, ';
  2.  
  3. $str = '[name=mickel[]][last=sdaddads]';
  4.  
  5. preg_match_all("/\[([$special_chr]+=[$special_chr]*)\]/D", $str, $match);
  6.  
how can i get name mickel[] with this pattern, it only gets last.
Aug 30 '10 #1
3 2125
smartic
150 New Member
any help please ?
Sep 2 '10 #2
JKing
1,206 Recognized Expert Top Contributor
I am not all that great with regular expressions.

What about after replacing all special characters searching for the [] and switching that to a special character.

Then you can run a regular expression to extract the two matches between the square brackets.

After that replace your special character with [].
Sep 2 '10 #3
kovik
1,044 Recognized Expert Top Contributor
Nesting is tough to deal with. Generally, you'd need more than a single regex call.
Sep 2 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Veverita | last post by:
Hi there I'm hoping that someone can help me with a question I have about javascript syntax. I got an html page that uploads an image and some text field to a database. What I'd like to do...
3
by: Eric Ellsworth | last post by:
Hi all, Does anyone have any bright ideas for Access' tendency to add square brackets when it parses queries, then tell you that the query syntax is invalid. In my case, I'm trying to do a LEFT...
9
by: Christine | last post by:
It has come to my attention that sometimes, when I open a Query in SQL View, the SQL that I see is not exactly the same as the SQL in the Query's Querydef. The difference I see (only occasionally)...
3
by: Derrick | last post by:
I'm writing a read/write properties file, how do I simluate the AppSettings method to get/set a value? Thanks in advance!
1
by: User1014 | last post by:
i.e. var foo = ; Do the ""'s just represent an array? and the "{}"'s represent a named value array?
3
by: Grande News | last post by:
Hi, I've got some PHP code that looks like this $cura= ord($data{$pnum*2}); $curb = ord($data{$pnum*2+1}); Notice the curly braces -- does using them make any difference, or will square...
0
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
A very noob type question... But what the properties defined on the method in square brackets called? Ive been using a lot of methods on top of them, Havent done much otherwise, So am planning...
1
by: Tim Couper | last post by:
It looks like you have a string which starts and ends with square brackets and is a repeated group of (integer, comma (and perhaps space)). What you don't have is a "string with a list in it" :-) ...
2
by: Edan | last post by:
Hello I'm trying to remove square brackets and everything between them from a string, using regular expressions I know how to use preg_replace, and know the basics of regex, but can't success....
8
hsriat
by: hsriat | last post by:
I need to compare a string with a regular expression that contains square brackets in itself. eg. If I test() a regExp ("^]", "i") with string "]Bold Text]", it should return true. But its...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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
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
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
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...
0
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,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.