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
0
votes
2 answers

jquery variable name with brackets

I am trying to use a variable for name with brackets and getting nowhere. I have this html With jQuery, I need to access the select by name…
Dss
  • 2,162
  • 1
  • 24
  • 27
0
votes
3 answers

Match the content of double square brackets

I have a string and I want to match the content of double square brackets: Example:

"Sed ut perspiciatis vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"

[[image file="2013-12/5s_1.jpg" alt="IPhone 5s"…

The_Guy
  • 215
  • 1
  • 2
  • 7
0
votes
1 answer

python: square backet in character class

I'm trying to match square brackets (using character class) in python. But the following code is not successful. Does anybody know what is the correct way to do? #!/usr/bin/env python import re prog = re.compile('[\[]+') print…
user1424739
  • 11,937
  • 17
  • 63
  • 152
0
votes
0 answers

Form issues with dynamically added input[] fields

I have a script that successfully adds input fields based on a users selection. For example However, when the form is submitted these values (array) do not show up in the post. If I add…
0
votes
2 answers

Why do I get square brackets when trying to convert array to JSON string using stringify

When I try to convert the array below to a string using JSON.stringify, I get to see empty square brackets only. I tried console.log to debug, but I do see the data I want to convert into a string, so what am I doing wrong here? Any help will be…
Aerial
  • 1,185
  • 4
  • 20
  • 42
0
votes
5 answers

Is it bad to use a "not declared array"? Does the "not declared" array have a proper name in programming?

I was trying to use a if...else statement with arrays without having to declare the arrays. I got it to work this way: if(['banana','apple','lemon'].indexOf(somevar) >-1) { //code } else if(['chicken','dog','elephant'].indexOf(somevar) >-1) { …
Samuel
  • 13
  • 3
0
votes
2 answers

Square brackets meaning string wont work

I am a bit stuck, trying to use this jquery line to enter a result from a select option into a text area This doesnt work $("#id[txt_17]").val($(this).find("option:selected").attr("name")); This…
Denise Field
  • 151
  • 1
  • 2
  • 10
0
votes
2 answers

How can I use line.replace to add space around any brackets in a string that are elements in another bracket set, through a loop?

brackets = {')', '(', '{', '}', '[', '>', ']', '<'} string_line = <[2{12.5 6.0}](3 -4 5)>' Basically I have to add space around any brackets in a string_line for brackets that are in the set. e.g. '[' becomes ' [ ' Assuming that I wouldn't know what…
Iann Wu
  • 155
  • 2
  • 12
0
votes
2 answers

laravel php square brackets definition

I'm trying to understand what the square brackets mean when trying to seed a database in Laravel. If I have a table with 2 fields title and body I'm wondering why square brackets are used instead of array(). Are the square brackets used for a short…
Kabu
  • 539
  • 2
  • 6
  • 18
0
votes
2 answers

Differences of the usage of the Square brackets [ ] beetwen "As String" and "As [String]"?

Someone can explain me which are the differences between using the Square brackets [ ] as this: Private Function FindItem([ListView] As [ListView], [ColumnIndex] As [Int32], [SearchString] As [String], Optional [IgnoreCase] As [Boolean] = False) As…
ElektroStudios
  • 19,105
  • 33
  • 200
  • 417
0
votes
1 answer

Why is it required to return a reference from overloading bracket operators (OR: why is an lvalue not returned otherwise)?

I've tried overloading the bracket operators for a class, to make accessing the array less tedious. What I don't understand is, why is it neccesary to declare the return type of the overload function as a reference? Why is it not an lvalue to begin…
Fulluphigh
  • 506
  • 1
  • 8
  • 21
0
votes
2 answers

Overloading 2D array operator and throwing exception

I've been thinking this through and didn't come up with anything useful. I have matrix represented by 2 classes: class CMatrix { public: CMatrixRow * matrix; int height, width; CMatrix(const int &height, const int &width); …
0
votes
2 answers

How can I echo square brackets in php

I want to echo the following code, but its not working:
user1721135
  • 6,864
  • 8
  • 34
  • 63
0
votes
1 answer

JS syntax for checkbox name attribute with square brackets

This function limits the number of checkboxes selected by the user, but I'm having trouble getting it to work when the name attribute has square brackets (i.e. name=baz[]). For some reason I can't get this code to work in jsfiddle, but it's based on…
Chaya Cooper
  • 2,566
  • 2
  • 38
  • 67
0
votes
1 answer

form variable names with square brackets in

when upload files, I make something like 'preview'. It stores form variables as for(i=0;i
el Dude
  • 5,003
  • 5
  • 28
  • 40