Questions tagged [square-bracket]

The symbols "[" and "]", commonly used in programming languages. Please use this tag only if the specific usage of these symbols is a relevant part of the question.

Overview

The square brackets "[" and "]" are special cases of brackets, along with parentheses and curly brackets (or braces) ("{", "}").

Uses

Square brackets have many uses in most programming languages, such as:

279 questions
3
votes
3 answers

sed command returns error about Unmatched (

I need to get rid of the double square brackets, I only need them once. However I get the error below after this command: sed -ri 's/("opening_hours": \[\[)(.*?)(\]\]/"opening_hours": \[\2\]/' ./foo.txt Error: sed: -e expression #1, char 60:…
jjk
  • 592
  • 1
  • 6
  • 23
3
votes
1 answer

Command with 'creates' is not idempotent when using filenames with square brackets

I have a task that creates multiple files, if they not exists. It works, until a filename is used as item that contains a pair of square brackets. I've tried to escape with backslashes and {% raw %} tags, but it does not work. Test playbook: --- -…
jan-di
  • 755
  • 7
  • 16
3
votes
1 answer

Is this a correct characterisation of the behaviours of square brackets in Scheme, Racket, Common Lisp, and Clojure?

I've recently done some digging. Due to my lack of Lisp experience, I want to verify what I've found. Is this a correct characterisation of the behaviours of square brackets in Scheme, Racket, Common Lisp, and Clojure? R5RS and R7RS Scheme: Square…
J. Mini
  • 1,868
  • 1
  • 9
  • 38
3
votes
0 answers

Check if parameter is present in JSON object at any depth

A api returns a JSON response at undefinable depth where some elements may or not be included. How do I check if a property is present? Some of the parameters include weird names like "@param" or "$". Example for this follows. I wrote a check for…
chris
  • 31
  • 3
3
votes
0 answers

Inconsistency with bracket notation in object property accessors for dynamically named constructor-function. Is there an explanation?

I want to dynamically create objects of dynamically named class (sorry JS, I got used to call them classes) via dynamically named anonymous function. In this answer I found out that... As of ES2015, the function created by an anonymous function…
3
votes
2 answers

PHP JSON Encode square bracket

I have a simple JSON array I am trying to encode. Inside of the JSON string I need another array in square brackets. I am unable to figure out how to make the internal brackets square. Any advice? Here is my code $data = [ "item" => ["id" =>…
Robert Dickey
  • 816
  • 14
  • 35
3
votes
1 answer

grok filter (regex) to extract string within square brackets

My application log entries are given below: 2015-06-24 14:03:16.7288 Sent request message [649b85fa-bfa0-4cb4-8c38-1aeacd1cbf74] sometext 2015-06-24 14:38:05.2460 Received response message [649b85fa-bfa0-4cb4-8c38-1aeacd1cbf74]…
VinothNair
  • 614
  • 1
  • 7
  • 24
3
votes
3 answers

Bash double bracket regex comparison using negative lookahead error return 2

On Bash 4.1 machine, I'm trying to use "double bracket" [[ expression ]] to do REGEX comparison using "NEGATIVE LOOKAHEAD". I did "set +H" to disable BASH variable'!' expansion to command history search. I want to match to "any string" except…
Rick Liu
  • 91
  • 1
  • 6
3
votes
1 answer

latest eclipse luna square brackets are not working in editors / german keyboard

In the latest version of eclipse luna it is not possible to use square brackets in any editor. I have a german keyboard and I don't want to switch to english layout. Under preferences -> general -> keys it is not possible to find the key combination…
jet miller
  • 275
  • 2
  • 17
3
votes
4 answers

jQuery - Dynamically amend Input name with multiple dimensional array

I have an input field which looks something like this... I need to change the value in the third set of square brackets when a user clicks on a button... so something…
Tom
  • 12,776
  • 48
  • 145
  • 240
2
votes
2 answers

What is the difference between [myString length] and myString.length in objective-c?

I'm currently learning objective-c. What exactly do the square braces around things signify and is there any difference between using that and using a period (I'm from a .NET world so this would be simpler for me). Thanks.
Matt B
  • 741
  • 3
  • 10
  • 17
2
votes
1 answer

PHP preg_replace square brackets

How could I replace some markup in this format: [a href="/my_page" style="font-size: 13px"]click me[/a] to click me using preg_replace()? I will need to allow for more attributes as well.
Mark White
  • 46
  • 1
  • 4
2
votes
1 answer

resharper search with pattern square bracket

how can I escape "[" in Resharper 6s Structural Search (C#). If i am searching for a pattern which contains a square bracket i just got the info: pattern is ambiguous. Is there any documentation of the syntax? I can't find a syntax documentation on…
Daniel Bişar
  • 2,663
  • 7
  • 32
  • 54
2
votes
3 answers

Is there any reason to write a database column between square brackets?

I am maintaining a database created by another person in SQL Server. In one table I found a column whose name is between square brackets. The name of the field is desc and it is stored in the table as [desc]. The other fields are stored without…
CiccioMiami
  • 8,028
  • 32
  • 90
  • 151
2
votes
2 answers

Javascript Square Bracket Notation Multiple Dynamic Properties

This may sound a bit unusual, I've never needed to use square bracket notation in this way before, and racking my brains I can't think of a way to produce the desired outcome. I'm implementing a callback wrapper to maintain the reference of this…
AshHeskes
  • 2,304
  • 1
  • 21
  • 27