Questions tagged [curly-brackets]

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.

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

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

  • identify code blocks;
  • create lists and arrays;
  • pass arguments to commands in TeX.
82 questions
3
votes
1 answer

Python 3.4 - Regular Expressions For Matching Innermost curly brackets

I am trying to code a Python regular expression for matching innermost curly brackets, i.e. curly brackets which can contain any number of characters other than another pair of curly brackets. As an example, I would like the following…
martin_0004
  • 357
  • 1
  • 2
  • 15
3
votes
3 answers

What is the meaning of curly brackets at the end of a js file reference?

I have seen a code like this and wonder what that curly brackets for, is it some kind of argumant pass?
Sarge
  • 388
  • 1
  • 4
  • 22
2
votes
2 answers

Using curly braces in an email / article to insert the customers name

I have looked and looked for an example on this, but the only ones I have found are echoing the result of the str replace like this : $malestr = str_replace("{name}", "$name", $rawstring); echo "$malestr"; But this is not what I want, what I am…
Iain Simpson
  • 441
  • 4
  • 13
  • 29
2
votes
2 answers

Javascript, adding things in curly bracket and definition

i'm in the process of modifying this excellent javascript library for autocomplete-ing html input see here... as i need to pass some extraparameters to the Ajax call. Actually i'm looking for something non destructive so that it can manage a default…
lctv31
  • 119
  • 3
  • 12
2
votes
1 answer

Joomla: K2 - How to strip out curly brackets from meta description using preg_replace

I need to strip out some curly brackets from the meta description which is created by joomla/K2. I found two php solutions to strip unneeded curly brackets: $description = preg_replace( '/{.+?}/', '', $description); and $metaDescItem =…
Christoph
  • 23
  • 4
2
votes
4 answers

PHP short way to echo string?

In PHP we echo strings this way : echo 'string'; But i saw PHP frameworks like Laravel and scripts echo strings using Curly Brackets : {string} How i can do that without using any PHP framework? It's not necessary to use Curly Brackets if there is…
Amr SubZero
  • 1,196
  • 5
  • 19
  • 30
2
votes
3 answers

Why JS throws syntax error, if there is a linefeed between return and {

I always thought, that new lines in JS sourcecode doesn't matter. Why new lines do matter sometimes? Error: function x(y) { return { y : y, z : y*2 } } console.info(x(5).z); Throws a SyntaxError: missing ; before statement…
Inherent
  • 183
  • 1
  • 1
  • 13
2
votes
3 answers

What does {0} mean in a string literal, for example in Console.WriteLine?

I'm learning C# and came across this small piece of code: { class Program { static void Main(string[] args) { int age = 20;// declaring variable and assign 20 to it. Console.WriteLine("You are {0} years…
Force444
  • 3,321
  • 9
  • 39
  • 77
2
votes
2 answers

PHP SimpleXML to JSON Encode single element array

I am trying to parse xml with php into a single element json array. This is what I have: $t = array(); $a=array("url"=>$test->channel->item->link); array_push($t,$a); echo json_encode($t);; Which gives me…
jQuerybeast
  • 14,130
  • 38
  • 118
  • 196
2
votes
1 answer

Brace styles in C# in VS2012

I'd like to configure the auto formatting brace styles to my preference. I've looked through all the option and can't quite get it how I like it. Here is a sample of my preferred format: if (condition && anothercondition ) { DoStuff(); } else…
DJL
  • 2,060
  • 3
  • 20
  • 39
1
vote
1 answer

Using Mustache with joomla

I am trying to use Mustache.php with Joomla. What I would like it to do is check the whole page for the curly brackets and then change {{name}} for PERSONS NAME etc etc. I have tried playing around with it with the example they have on the website…
Iain Simpson
  • 441
  • 4
  • 13
  • 29
1
vote
1 answer

Insert into form curly brackets alias with Jquery / Javascript

I am not even sure if this is even possible or how easy it is, but what I am trying to work out is how to, if it is possible, to use jquery or javascript to insert an alias for a form field / curly brackets where the cursor currently is selected on…
Iain Simpson
  • 441
  • 4
  • 13
  • 29
1
vote
1 answer

Vim: regex in search function not working as expected to find left curly brackets

I am trying to compose a Vim script function to help format where the left braces are located at in C like functions blocks. function! FixLeftBraces() "Set the cursor to the top of the file call cursor(1,0) while search(".\+{",'We') > 0 …
MrDaniel
  • 583
  • 1
  • 7
  • 19
1
vote
1 answer

I am unable to use [brackets] and {braces} in Gedit on Mac OS X (snow leopard)

I have searched everywhere. The bug tracking system on http://projects.gnome.org/gedit/ is broken. Don't know how to use IRC(even if I did, irc.gnome.org is a very weird site of which i understand nothing). You are my last hope: How on earth do I…
Jagil
  • 11
  • 1
  • 4
1
vote
1 answer

PHP - Lock-contentions with curly braces?

One of my colleagues wrote this worker class (used in Yii 1.1/Pheanstalk). In code review I stumbled upon the two blocks of curly braces and ask him why he did it this way. He said he wants to prevent lock-contentions. I've never heard about it…