smallseo.info

brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.

regular expressions with escaping round brackets

I am trying to write the expresion that will accep fallowing phone numbers format:

508 736 756
505050505
+48 505 505 505
(+48) 505 505 505
++48 505 505 505
(++48) 505 505 505
(23)692 36 99
23 692 36 99

I have wrote the fallowing expresion

^(([+]{0,2}?)?([+]{0,2}?)?([0-9 ]+)?)$

How ever this expresion covers only the format listed below:

508 736 756
505050505
+48 505 505 505
++48 505 505 505
23 692 36 99

I have issue with escaping the round brackets characters ( , ) that is why i cant cover the fallowing formats

(+48) 505 505 505
(++48) 505 505 505
(23)692 36 99

I have tried escaping them with backslash but it wouldn't work for some reason.

...[(]?[+]{0,2}[)]?...

DEMO: https://regex101.com/r/hY5tG4/2


Source: (StackOverflow)

Python: What does the use of [] mean here?

What is the difference in these two statements in python?

var = foo.bar

and

var = [foo.bar]

I think it is making var into a list containing foo.bar but I am unsure. Also if this is the behavior and foo.bar is already a list what do you get in each case?

For example: if foo.bar = [1, 2] would I get this?

var = foo.bar #[1, 2]

and

var = [foo.bar] #[[1,2]] where [1,2] is the first element in a multidimensional list

Source: (StackOverflow)

Special uses of this syntax in PHP? (Triple 'Angle Brackets')

Given the following code:

$myString = <<<script
   .
   .
   .
 script;

Thanks to the answers on the original version of this question, I understand <<< to be heredoc syntax, treated as double quotes without the need for escaping quotes.

Taking this a step further, how is this best exploited? Specifically, should this ease the strain of dealing with mixed quote strings containing code syntax?

i,e..

attribute="name-like string" attribute="property: 'value("value")';"

The thought is this may be useful (if implemented the way I am now guessing) especially when dealing with greater complexity and/or looking out for code injection. Again, looking for any scenarios where the heredoc for is particularly useful or exploitable.


Source: (StackOverflow)

What is the difference between square brackets and single quotes for aliasing in SQL Server?

I have seen some people alias column names using single quotes eg:

select orderID 'Order No' from orders

and others use square brackets eg:

select orderID [Order No] from orders

I tend to use square brackets. Is there any preference/difference?


Source: (StackOverflow)

round brackets in xaml syntax

when I'm using ColorAnimation to change Background of control i'm using following syntax:

<ColorAnimation Duration="0:0:0.5" 
 Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)" 
 To="Black" />

I'm very happy it works but I couldn't find any information about round braces in xaml syntax reference ...

So could you please explain where does this syntax come from and what does the round brace actually mean?

It would be very helpful. Thanks


Source: (StackOverflow)

Visual studio 2010 + resharper bracket indentation problem

I'm using VS 2010 + resharper, and i'm tired reformatting bracket indentation in code as i want it. As example if i have code like:

operators.Keys
    .ToList()
    .ForEach(k => filters
        .AddRange(CustomHtmlHelpers.GetIdAndValueListByPrefix(queryString, k)
            .Select(t => new QueryFilter()
            {
                Operation = operators[k],
                PropertyName = t.Item1,
                Value = t.Item2
            })))

And if i put ; in the end VS (or resharper) 'fixes' bracket indentation so code becomes like:

operators.Keys
    .ToList()
    .ForEach(k => filters
                        .AddRange(CustomHtmlHelpers.GetIdAndValueListByPrefix(queryString, k)
                                    .Select(t => new QueryFilter()
                                    {
                                        Operation = operators[k],
                                        PropertyName = t.Item1,
                                        Value = t.Item2
                                    })));

Same happens if i use resharper's code cleanup. I probably could turn off automatic code reformatting on ; but i need it in other situations. I tried changing code formating options both in VS and resharper setting but never got indentation as i want it.

How could i configure vs or resharper so that it would not do more than one tab formating? Or maybe there is other plugin i can use (together with r#) specificly for this purpose?

EDIT: for anyone interested in this problem here is same question in r# forum http://devnet.jetbrains.net/thread/304794 anyone who would like to see better nested code indentation from r# are welcome to vote for it here http://youtrack.jetbrains.net/issue/RSRP-88220


Source: (StackOverflow)

consecutive operators and brackets

I'm just trying to learn a bit of Perl and have come across this:

foreach $element (@{$records})
{
    do something;
}

To my newbie eyes, this reads: "for each element in an array named @{$records}, do something" but, since that seems an unlikely name for an array (with "@{$" altogether), I imagine it isn't that simple?

I've also come across "%$" used together. I know % signifies a hash and $ signifies a scalar but don't know what they mean together.

Can anyone shed any light on these?


Source: (StackOverflow)

Regular Expressions (Normal OR Nested Brackets)

So I'm completely new to the overwhelming world of Regex. Basically, I'm using the Gedit API to create a new custom language specification (derived from C#) for syntax-highlighting (for DM from Byond). In escaped characters in DM, you have to use [variable] as an escaping syntax, which is simple enough. However, it could also be nested, such as [array/list[index]] for instance. (It could be nested infinitely.) I've looked through the other questions, and when they ask about nested brackets they only mean exclusively nested, whereas in this case it could be either/or.

Several attempts I've tried:

  • \[.*\] produces the result "Test [Test[Test] Test]Test[Test] Test"
  • \[.*?\] produces the result "Test [Test[Test] Test]Test [Test] Test"
  • \[(?:.*)\] produces the result "Test [Test[Test] Test]Test[Test] Test"
  • \[(?:(?!\[|\]).)*\] produces the result "Test [Test[Test] Test]Test[Test] Test". This is derived from http://stackoverflow.com/a/9580978/2303154 but like mentioned above, that only matches if there are no brackets inside.

Obviously I've no real idea what I'm doing here in more complex matching, but at least I understand more of the basic operations from other sources.


Source: (StackOverflow)

int([x[, base]]). Square brackets in functions in Python documentation? [duplicate]

This question already has an answer here:

What is the meaning of the square brackets inside the round brackets of a function in the Python documentation?

E.g.:

help([object])

or

int([x[, base]])


Source: (StackOverflow)

How does the ~[] construction work in JavaScript?

I've come across a working JavaScript code that I can't explain. For example:

  • +[]===0
  • -[]===0
  • ~[]===-1
  • ~-~[]===-2
  • ~-~-~-~-~[]===-5
  • ~-~-~-~-~[]+~[]===-6
  • ~+~[]===0
  • ~+~+~[]===-1
  • ~+~+~+~[]===0

Can you explain the logic of these expressions?


Source: (StackOverflow)

Problem with brackets in jQuery Form Data when sending data as json

I have the object

    var dataformdata={"key1":"value1","key2":"value2"};

then I add some more values with the same key(key3) like so

    dataformdata.key3 = [];
    dataformdata.key3.push("value3");
    dataformdata.key3.push("value4");

i do the above in an each slope. it all works except when sending the dataformdata object via the jQuery ajax function in the browser console i see that there are brackets in the key ...

$.ajax({ type: "POST", url: "/", data: dataformdata,...

This is what i see in the browser console:

key1:value1
key2:value2
key3%5B%5D:value3
key3%5B%5D:value4

it should work because in the jQuery.ajax() docs it says

Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting

But why are the brackets (%5B%5D) in the key?


Source: (StackOverflow)

What is this JavaScript construct: " = [y for each ...]"

myColl.y = [y for each (y in myColl.y) if (y != myThing.getY())];

I understand what this is doing, returning all the 'y' items that are not the current one...

But, what is the concept called here with the brackets? I would like to read up on what this is , syntax, etc.


Source: (StackOverflow)

How do i replace [] brackets using SED

I have a string that i am want to remove punctuation from.

I started with

sed 's/[[:punct:]]/ /g'

But i had problems on HP-UX not liking that all the time, and some times i would get a 0 and anything after a $ in my string would dissappear. So i decided to try to do it manually.

I have the following code which works on all my punctuation that I am interested in, except I cannot seem to add square brackets "[]" to my sed with anything else, otherwise it does not replace anything, and i dont get an error, so I am not sure what to fix.

Anyways this is what i currently have and would like to add [] to.

sed 's/[-=+|~!@#\$%^&*(){}:;'\'''\"''\`''\.''\/''\\']/ /g'

BTW I am using KSH on Solaris, Redhat & HP


Source: (StackOverflow)

Angled brackets in Maven console ouput

Looking at the picture below, I noticed that Maven sometimes prints 3 angled brackets (">>>" or "<<<") when invoking particular goals.

enter image description here

What do these angled brackets mean?

All other goal invocations are preceded by 3 hyphens ("---"). My guess is that goals (in this case, the devserver_stop goal) preceded by angled brackets are executed asynchronously. If that's the case, how can I make these goals be executed synchronously?


Source: (StackOverflow)

Automatic closing brackets for Vim

Is there any WORKING plugin for Vim 7.4 that would automatically close brackets ('{}', '[]', '()') and maybe insert some carriage returns (for '{}' at least)?

I know this question has been asked quite a few times but none of the answers either do not seem to work in vim 7.4 or the plugin has not been updated or something.

So far I've tried vim-smartinput, autoclose and delimitmate and NONE of these have managed to insert any closing characters even though I have enabled the plugins and they otherwise seem to be active. I don't know if there has been some changes in vim that somehow breaks these plugins. None of these plugins seem to be updated in a ~year at least. Any working solutions that would work with vim 7.4?


Source: (StackOverflow)