Search Results

Search found 489 results on 20 pages for 'brackets'.

Page 1/20 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Readability and IF-block brackets: best practice

    - by MasterPeter
    I am preparing a short tutorial for level 1 uni students learning JavaScript basics. The task is to validate a phone number. The number must not contain non-digits and must be 14 digits long or less. The following code excerpt is what I came up with and I would like to make it as readable as possible. if ( //set of rules for invalid phone number phoneNumber.length == 0 //empty || phoneNumber.length > 14 //too long || /\D/.test(phoneNumber) //contains non-digits ) { setMessageText(invalid); } else { setMessageText(valid); } A simple question I can not quite answer myself and would like to hear your opinions on: How to position the surrounding (outermost) brackets? It's hard to see the difference between a normal and a curly bracket. Do you usually put the last ) on the same line as the last condition? Do you keep the first opening ( on a line by itself? Do you wrap each individual sub-condition in brackets too? Do you align horizontally the first ( with the last ), or do you place the last ) in the same column as the if? Do you keep ) { on a separate line or you place the last ) on the same line with the last sub-condition and then place the opening { on a new line? Or do you just put the ) { on the same line as the last sub-condition? Community wiki. EDIT Please only post opinions regarding the usage and placement of brackets. The code needs not be re-factored. This is for people who have only been introduced to JavaScript a couple of weeks ago. I am not asking for opinions how to write the code so it's shorter or performs better. I would only like to know how do you place brackets around IF-conditions.

    Read the article

  • IF-block brackets: best practice

    - by MasterPeter
    I am preparing a short tutorial for level 1 uni students learning JavaScript basics. The task is to validate a phone number. The number must not contain non-digits and must be 14 digits long or less. The following code excerpt is what I came up with and I would like to make it as readable as possible. if ( //set of rules for invalid phone number phoneNumber.length == 0 //empty || phoneNumber.length > 14 //too long || /\D/.test(phoneNumber) //contains non-digits ) { setMessageText(invalid); } else { setMessageText(valid); } A simple question I can not quite answer myself and would like to hear your opinions on: How to position the surrounding (outermost) brackets? It's hard to see the difference between a normal and a curly bracket. Do you usually put the last ) on the same line as the last condition? Do you keep the first opening ( on a line by itself? Do you wrap each individual sub-condition in brackets too? Do you align horizontally the first ( with the last ), or do you place the last ) in the same column as the if? Do you keep ) { on a separate line or you place the last ) on the same line with the last sub-condition and then place the opening { on a new line? Or do you just put the ) { on the same line as the last sub-condition? Community wiki.

    Read the article

  • what is [] brackets in .net ?

    - by Freshblood
    Hello i have seen [] such brackets in c# very very rarely but when i start to learn asp.net i have seen them many times but still i couldn't understand what they does ? They are not part of code as using for arrays.For example [webmethods] which is just over the methods or there are some over classes. Are they part of .net or they are just tell something to CLR ? or ?

    Read the article

  • Regular Expression Help - Brackets within brackets

    - by adbox
    Hello I'm trying to develop a function that can sort through a string that looks like this: Donny went to the {park|store|{beach with friends|beach alone}} so he could get a breath of freash air. What I intend to do is search the text recursively for {} patterns where there is no { or } inside the {}, so only the innermost sandwiched text is selected, where I will then run a php to array the contents and select one at random, repeating process until the whole string has been parsed, showing a complete sentence. I just cannot wrap my head around regular expressions though. Appreciate any help!

    Read the article

  • What's Your Method of not forgetting the end brackets, parentheses

    - by JMC Creative
    disclaimer: for simplicity sake, brackets will refer to brackets, braces, quotes, and parentheses in the couse of this question. Carry on. When writing code, I usually type the beginning and end element first, and then go back and type the inner stuff. This gets to be a lot of backspacing, especially when doing something with many nested elements like: jQuery(function($){$('#element[input="file"]').hover(function(){$(this).fadeOut();})); Is there a more efficient way of remembering how many brackets you've got open ? Or a second example with quotes: <?php echo '<input value="'.$_POST['name'].'" />"; ?>

    Read the article

  • brackets in php templates

    - by Othman
    I have a script, and now it's the perfect time to have an option to change theme templates. I was looking forward to store these files in php files, or html files. with CSS file. I looked over some codes and I found that they use brackets to refer to the variable. Here's an example of a template block: <div class='block_div'> <center>{title}</center> {content} </div> I know that I can use PHP vars usering <?=$var;?>. However, I think the one above is better, and I looked over the web to find anything about it but I couldn't. My Question is how I can use these brackets in my php or html code. to let the user changing the template only not the code!

    Read the article

  • What's the meaning of the angle brackets on LINQ methods in Intellisense? (Contains<>, Count<>, Dis

    - by user312758
    They usually involve generics. But some methods with generics don't have them, and not all extension methods have them. They've just "been there" since day one, we've all seen them; but I realized I still don't know what they mean, and I can't find the answer anywhere. Now it's really bugging me. Google just turns up results that are about XML, etc. Is this officially documented anywhere? Thanks. EDIT: Well that's just great. Since I just created an account to make my first Stack Overflow post, to get an answer for this burning question; I'm not allowed to post my pretty Intellisense picture, or create a new tag "angle-brackets". I love Stack Overflow, but... what a welcome! Maybe my problem is that they aren't actually called "angle brackets"... ?? Anyway, I guess if you really want to see my beautiful screenshot you could manually go to: http://www.freeimagehosting.net/uploads/6a6c2f3268.png Bump me up please so I can include it in the post, thanks. ;)

    Read the article

  • Get rid of gray brackets arond editable text in restricted Word docs

    - by Brendan
    I'm trying to work out a problem in Word that I thought was simply a glitch from 2003 until we upgraded to 2010 and the problem persisted. For our corporate letterhead, we set up the template with placeholder text, highlight the text, and then make the document read-only with the exception of the selected text. The editable text turns yellow and gains these brackets around them: Once these brackets appear, they'll always show on the screen. That I can handle, though I'd like to learn how to hide them on-screen if that's possible. When the document is printed while protected, it works fine. When the document is printed while NOT protected, part of the bracket shows up on the paper! I guess the ultimate question is, how can I get rid of the brackets altogether? I can see why they exist but in my use case they create more problems than they solve. I'd like someone to be able to read the doc without seeing brackets, and I'd like other people in my department to be able to print without having to re-restrict it first. I tried to turn off bookmarks because that's what seemed to come up when I searched around, but that didn't do anything.

    Read the article

  • Table/column names enclosed in square brackets, even though their names consist of legal characters

    - by AspOnMyNet
    Square brackets allow you to use names for columns or aliases that contain characters not permitted for column names or aliases. a) I’ve noticed that lots of times table and column names are enclosed inside square brackets, even though their names consist of perfectly legal characters. Why is that? b) As far as I know, square brackets enclosing object’s name aren’t actually a part of that name. Thus, if we create a table named [A]: CREATE TABLE [A] ( … ) we can later reference it without using brackets: SELECT * FROM A But why isn’t the same true when I try to reference a column KEY from a table returned by CONTAINSTABLE function? Namely, if I omit the brackets enclosing column name, I get an error: SELECT ct.KEY FROM CONTAINSTABLE(fullText,*,'some_string') as ct thanx

    Read the article

  • What do you call this { character?

    - by John Isaacks
    When talking to another programmer I would refer to ( and ) as parentheses. I would refer to [ and ] as brackets. What do you refer to { and } as? I checked the wikipedia article and there were several names listed: curly brackets squiggly brackets definite brackets swirly brackets birdie brackets Scottish brackets squirrelly brackets braces gullwings Is there a term commonly used within programmers to identify these characters?

    Read the article

  • Remove and Replace multiple chars ( spaces, hyphen, brackets, period) from string in sql

    - by Muhammad Kashif Nadeem
    +39 235 6595750 19874624611 +44 (0)181 446 5697 +431 6078115-2730 +1 617 358 5128 +48.40.23755432 +44 1691 872 410 07825 893217 0138 988 1649 (415) 706 2001 00 44 (0) 20 7660 4650 (765) 959-1504 07731 508 486 please reply by email dont have one +447769146971 Please see the above given phone numbers. I need to replace all spaces, hyphen, period, brackets and leading 0 etc from these numbers. I need this format +447469186974 If number has leading plus sign then don't replace it otherwise I have to concatenate + sign with it. E.G +39 235 6595750 in this number I just need to remove spaces. +44 (0)181 446 5697 in this i need to removes spaces and brackets and 0 in between brackets i.e (0) 07825 893217 in this I need to replace leading 0 with + sign and remove spaces (415) 706 2001 in this replace '(' with + sign and remove ')' and spaces. 'please reply by email' This is the entry in phone number field and I just need to ignore this. +48.40.23755432 Remove period in phone number (765) 959-1504 Remove brackets and spaces and hyphen and add + sign in front of number. 7798724250 just need to add + sign in front of number 00 44 (0) 20 7660-4650 Need to remove leading 0 I.E '00' remove spaces and brackets and 0 in between brackets and hyphen and add + sign in front of number Only leading '0' will be replaced not anyother occourence of '0' The desired result is +447769146971 Should I use nested REPLACE, CHARINDES, PATINDES for each char I want to replace? Thanks.

    Read the article

  • Experiments in Wackiness: Allowing percents, angle-brackets, and other naughty things in the ASP.NET

    - by The Official Microsoft IIS Site
    Just because you CAN do something doesn't mean you SHOULD. However, it's always nice to do something crazy so that you can better understand a system. Warning: There is no warranty implied here. I'm loading the gun and showing you where to point it. If you point it at your foot, that's your business. Safety mechanisms exist for a reason and if you're going to to use this tip to just "get an app to work" but you're not sure why it's broken and you're just...(read more)

    Read the article

  • What RegEx should I use to return parameter names wrapped within brackets in an expression?

    - by burak ozdogan
    Hi, I have a set of expressions representing some formula with some parameters inside. Like: "[parameter1] * [parameter2] * [multiplier]" and many others like this. I want to use a regEx so that I can get a list of strings (List<string> ) which will have [paramter1] [paramter2] [multiplier] inside. I am not using regular expressions so often; if you have already used something like this I would appreciate if you can share. Thanks!

    Read the article

  • XSLT: How to escape square brackets in Urls

    - by ilariac
    I have a set of records from Solr where field[@name='url'] can have the following format: http://url/blabla/blabla.aspx?sv=[keyword%20keyword,%201] My understanding is that the square brackets denote an array syntax and I would like to use XSLT to remove the square brackets from all Urls. The reason for this is that I am using an Open URL resolver, which does not currently handle well those characters. The best option would be to strip the square brackets from all URLs before such resources are mediated by the Open URL resolver. There are cases where I have multiple occurrences of square brackets per Url. Can you please help me with this? Thanks for your help, I.

    Read the article

  • Grouping string by comma between brackets

    - by Myra
    Response to : http://stackoverflow.com/questions/1454913/regular-expression-to-find-a-string-included-between-two-characters-while-exclud Hi,I'm looking for a regex pattern that applies to my string including brackets: [1,2,3,4,5] [abc,ef,g] [0,2,4b,y7] could be anything including word,digit,non-word together or separated. I wish to get the group between brackets by \[(.*?)\] but what is the regex pattern that will give me the group between brackets and sub-group strings separated by commas so that the result may be following ?? Group1 : [1,2,3,4,5] Group1: 1 Group2: 2 Group3: 3 Group4: 4 Group5: 5 Group2 : [abc,ef,g] Group1: abc Group2: ef Group3: g etc .. Thank you for your help

    Read the article

  • PHP: form input field names containing square brackets like field[index]

    - by gidireich
    Hi, I've seen lot of code that handle forms, which creates input fields with names containing square brackets. I understand that this is being somehow converted to PHP arrays when a PHP script examines the $_POST variable. My questions about this: What is the mechanism behind? At which point this names that merely contain brackets are converted to arrays? Is this a feature of the HTPP protocol? Of web servers? Of the PHP language? Continuing the previous question, is this a commonly used hack or a normal programming tool? What are (all) the rules of using brackets in input field names? Can multidimensional arrays be created this way? Thanks, Gidi

    Read the article

  • Brackets around Stored Procedure in ADODB Command Text

    - by KennerL90
    Help me understand why this is happening! I use the ADODB.Command object. The Command Text is set to the Stored Procedure Name. Sometimes, if I DON'T add brackets around the stored procedure name, I get a Syntax Error or Access Violation error. Sometimes, if I DO add brackets around the stored procedure name, I get a Syntax Error or Access Violation error.

    Read the article

  • accessing array values without square brackets in php

    - by amb
    In php how can I access an array's values without using square brackets around the key? My particular problem is that I want to access the elements of an array returned by a function. Say function(args) returns an array. Why is $var = function(args)[0]; yelling at me about the square brackets? Can I do something like $var = function(args).value(0); or am I missing something very basic?

    Read the article

  • Regular expression to extract text between either square or curly brackets

    - by ObiWanKenobi
    Related to my previous question, I have a string on the following format: this {is} a [sample] string with [some] {special} words. [another one] What is the regular expression to extract the words within either square or curly brackets, ie. {is} [sample] [some] {special} [another one] Note: In my use case, brackets cannot be nested. I would also like to keep the enclosing characters, so that I can tell the difference between them when processing the results.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >