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
2
votes
1 answer

C++ square bracket overloading with and without const/ampersand

I am writing C++ code, and ran into a case where I wish to overload the square bracket operator for my class. From various sources, I find that you usually make two methods to do this, one with the const keyword, and one without the const keyword,…
2
votes
3 answers

PHP replace patterns in string with URLs

I have a few hundred html files that I want to show on a website. They all have links in them in the following format: [My Test URL|https://www.mywebsite.com/test?param=123] The problem is that some urls are split up so: [My Test…
user754730
  • 1,341
  • 5
  • 31
  • 62
2
votes
2 answers

How do I look in a string with text inside quotations, but ignoring anything inside brackets using regex?

For example my string is: var str = 'Hello "Counts1 [ignore1] Counts2 [ignore2] Counts3 [ignore3] Count these too"'; How would I get everything inside the string that is inside quotations ignoring the characters inside the brackets? So for example…
user15585067
2
votes
2 answers

Python: List pulled from txt file as string not recognised as list

I saved the show data from the epguide API in a txt file, which looks like this: [{'epguide_name': 'gooddoctor', 'title': 'The Good Doctor', 'imdb_id': 'tt6470478', 'episodes': 'http://epguides.frecar.no/show/gooddoctor/', 'first_episode':…
dizcotec
  • 23
  • 3
2
votes
1 answer

Regex for getting information from square brackets

I'm attempting to make something like shortcodes in WordPress, and I'm looking for a regex that will take something like [title:This is a title] and turn it to just This is a title. It would also be useful if someone could suggest a way to take…
Samsquanch
  • 8,866
  • 12
  • 50
  • 89
2
votes
4 answers

Accessing multiple nested objects

I am making a global data storage for my app (Angular JS app - but this is a question about JS, not Angular particularly). I've set up a service that sets the data, gets the data, etc. It looks like so: angular.module('core').factory('dataService',…
4lackof
  • 1,250
  • 14
  • 33
2
votes
3 answers

How to expand an argument with a range in square brackets in a bash script?

I want to use strings containing numbers as input to my script. This list can be rather long and may contain consecutive ranges of numbers, so I thought about doing ls style list specification. However, how can I expand this list in my script? To be…
Renat
  • 223
  • 3
  • 8
2
votes
2 answers

What would cause the BASH error "[: too many arguments" after taking measures for special characters in strings?

I'm writing a simple script to check some repositories updates and, if needed, I'm making new packages from these updates to install new versions of those programs it refers to (in Arch Linux). So I made some testing before executing the real…
José
  • 354
  • 5
  • 18
2
votes
0 answers

Dynamic Object Reference data.d.results.[fieldobjectname].[fieldname] in JavaScript

BACKGROUND: Using SharePoint 2013, calling a REST Ajax call in javascript. When successful, this returns results in a data set, which I put in a variable called data. My OData syntax uses $expand on a SharePoint Person {the datatype} field, such…
2
votes
1 answer

Using square brackets to concatenate things in Javascript?

Anyone know why this isn't working? $('#screen').css({ 'background-image': [bg_num == 1 ? 'josh' : 'jessi'] + '_background.jpg', 'background-color': 'red' }); The background color is getting set, but the image is not. I've not really had much…
Ian Storm Taylor
  • 8,520
  • 12
  • 55
  • 72
2
votes
3 answers

Unclosed square bracket doesn't throw error in jquery

$('#parent_tab [href="#tab1"').click(); The above line works fine and the tab gets selected in other browsers but not safari. I had to close the square bracket of href as follows in order to make it work in Safari. $('#parent_tab…
Vamshi
  • 97
  • 10
2
votes
5 answers

How to remove a number inside brackets at the end of string with regex

Looking to have a recursive function that takes a string and removes the ending '[x]'. For example 'abc [1] [3]' needs to be 'abc [1]'. The string could also be 'abc [1] [5] [2]' and would need to be 'abc [1] [5]'. I'm trying…
Kelly Redd
  • 31
  • 1
  • 3
2
votes
3 answers

How do i store a set of values in an array without using square brackets, but by using pointers

In C programming, how can a store a set of values entered by the user into an array using only pointers and no square brackets?
Maia8
  • 23
  • 1
  • 3
2
votes
1 answer

RegEx for bracket in Notepad++

I'm trying to create a special RegEx function in notepad++ to fix some subtitle txt files originally in Softni format, which use square brackets as special characters for italic command. These files are originally intended for Softni products, but…
mboufleur
  • 31
  • 4
2
votes
1 answer

C fscanf to read between square brackets

I have a file which includes datas as [name surname] [birthday] [id] when i try this code while(fscanf(file,"%s %s %s",name,bdate,uid) == 3) bdate gets surname] as a value how can i read informations between square brackets. thanks.
umtkas
  • 62
  • 9