Rectangle 27 7

You can't declare methods inside a method.. It's not about brackets.. It's about syntax.

First thing, throw away the code that you have written.. Lets start fresh..

  • Create a class say Demo
  • Add a method to that class, getUserInput()
  • Have a constructor (0-arg)
  • Now, your program starts executing from main().. If you want to take user input.. Call your getUserInput() method from here.. As the first statement..
getUserInputMethod()
instance variables

After this, your getUserInput() will return control to your main() method.. You can proceed with your code from there..

not only that, addVehicleBooking is never used anyway so we can't guess what he needs to do with his "inner" method

@TecHunter.. Actually he has asked this question before.. There he had all those code inside a constructor. I told him to have a method, and let it do all the I/O.. And then you can create class instance from there... May be he's a little confused with that..

Java - Trouble with brackets - Stack Overflow

java brackets
Rectangle 27 4

This regex /<{1}[^<>]{1,}>{1}/g should replace any text in a string that is between two of these <> and the brackets themselves with a white space. This

var str = "<hi>How are you<hi><table><tr>I<tr><table>love cake<g>"
  str = str.replace(/<{1}[^<>]{1,}>{1}/g," ")
  document.writeln(str);
var stripHTML = str.mixedCase(/<{1}[^<>]{1,}>{1}/g,"")
var mixedCase = punctuationless.replace(/\s{2,}/g);

and replace mixedCase with stripHTML in the line after, it will probably work

javascript - Remove HTML tags in script - Stack Overflow

javascript python regex replace
Rectangle 27 2

The []* means zero or more instances of what is in the brackets. In this case the empty string is matched since it is part of your string.

If zero or more characters at the beginning of string match the regular expression pattern...

The string 'a' has the empty string '' at the beginning if you will. You could say the reg ex is seeing it as ''+'a' where the beginning matches your pattern.

Okay I understand what [^ab]* matches an empty string from str. What is being matched with 'a' from str

Okay, I think I misunderstood the difference between match and full match. so match will match any part of str, full match makes sure the entire str matches the pattern right ?

No, match will match the start of a string, see the quote from the docs in the answer.

python - What does [^ab]* match with a? - Stack Overflow

python regex
Rectangle 27 16

Thank you for everyone's assistance and pushing to get rid of the eval statement. Variables needed to be in brackets, not dot notation. This works and is clean, proper code.

Each of these are variables: appChoice, underI, underObstr.

if(typeof tData.tonicdata[appChoice][underI][underObstr] !== "undefined"){
    //enter code here
}

javascript - How to check if object property exists with a variable ho...

javascript object
Rectangle 27 4

It should be noted that not only will the caret (^) behave differently within the brackets, it will have the opposite result of placing it outside of the brackets. Placing the caret where you have it will search for all strings NOT beginning with the content you placed within the brackets. You also would want to place a period before the asterisk in between your brackets as with grep, it also acts as a "wildcard".

grep ^[.rwx].*[0-9]$

This should work for you, I noticed that some posters used a character class in their expressions which is an effective method as well, but you were not using any in your original expression so I am trying to get one as close to yours as possible explaining every minor change along the way so that it is better understood. How can we learn otherwise?

regex - Grep for beginning and end of line? - Stack Overflow

regex linux bash grep
Rectangle 27 4

Why do you have the brackets around digit? It should be

NSLog("%@", digit);

You're also missing an = in the first line...

NSString *digit = [[sender titlelabel] text];

objective c - Using NSLog for debugging - Stack Overflow

objective-c xcode debugging nslog
Rectangle 27 3

Had the exact same problem. The problem is with the brackets of the child properties (models[0].Roles[0][Code] instead of models[0].Roles[0].Code). You will need a parse function before sending the data to the server (or update the default model binder).

Kendo support sent me a solution:

.Update(update => update.Action("Update", "Controller").Data("serialize"))
.Create(create => create.Action("Create", "Controller").Data("serialize"))

Later in the view (or a JS file)

<script>
    function serialize(data) {
        for (var property in data) {
            if ($.isArray(data[property])) {
                serializeArray(property, data[property], data);
            }
        }
    };

    function serializeArray(prefix, array, result) {
        for (var i = 0; i < array.length; i++) {
            for (var property in array[i]) {
                result[prefix + "[" + i + "]." + property] = array[i][property];
            }
        }
    }
</script>

If your plans are to use a grid to edit that collection of complex objects, I'll tell you right now, you will regret your decision. Just a friendly warning to save you a few days of wasted time :)

This fixes the issue! But it looks like a bug to me, did Kendo support said something about this?

They said I shouldn't use complex types in grids. That I should use a flattened object instead.

asp.net mvc - Model binding issues with Kendo objects with complex chi...

asp.net-mvc grid model-binding kendo-grid
Rectangle 27 2

You can just go over the string character by character, remembering how deep you are in brackets, and replace commas with vertical bars if needed.

#!/usr/bin/perl
use warnings;
use strict;

my $string = '(rupert, paul, 23, 8, [{fin, dan, jack},{bill,34,26,49},{84,28}],{34,jack,bon})';

my $inside;
for my $pos (0 .. length($string) - 1) {
    my $char = substr $string, $pos, 1;
    $inside++ if $char =~ /[[{]/;
    $inside-- if $char =~ /[]}]/;
    substr $string, $pos, 1, '|' if ',' eq $char && $inside;
}
print $string, "\n";

perl regex selectively replace the record separator - Stack Overflow

regex perl
Rectangle 27 2

As @trincot pointed out [^\s<] doesn't mean if it is not a space or non-breaking space. It's a character class and whatever is between those brackets has a mean of a single character only. So it means if it is not a space or < or & or...

You need to check if very next character is a word character \w which denotes [a-zA-Z0-9_], then consider to add an space at zero-width assertion of used positive lookahead:

preg_replace("~</a>\K(?=\w)~", ' ', $text, -1, $count);
 echo "Number of occurrences in type $type is $count \n";
</a>    # Match closing anchor tag
\K      # Reset match
(?=\w)  # Look if next character is a word character
preg_replace("~</a>\K(?!&nbsp;)~", '&nbsp;', $text, -1, $count);

This adds a non-breaking space when there is no non-breaking space after closing anchor tag.

but in here where are you handling the specific </a> tag ?

and just confirming ~ means the same like opening and ending of regex ?

Yes, it's one of the allowed delimiters. @RaheelKhan

php - Removing spaces after anchor tag with preg replace - Stack Overf...

php regex preg-replace html-parsing
Rectangle 27 3

With regular expressions the \w special characters means "any word characters" and the \d means digits. The ^ in the brackets means negate or basically anything that isn't in the brackets. The code below would echo "true" or a 1 to indicate the string has non-word characters in it.

$string = '% # ^ . ! @ & ( ) + / " ? ` ~ < > { } [ ] | = - ;'
echo preg_match('~[^\w\d]~', $string);

trying to be the fist - you forgot that strings limiting with quotes ;-)

regex - PHP Special Characters Test - Stack Overflow

php regex special-characters
Rectangle 27 2

Unfortunately, there is no RTTI generated for Generic parameters. The only way to discover the value of T in a Generic container like TList<T> is to get the TRttiType for the target field itself, call its ToString() method to get its class name as a string, and parse out the substring that is between the brackets. For example:

uses
  ..., System.StrUtils, System.Rtti;

var
  Ctx: TRttiContext;
  s: string;
  OpenBracket, CloseBracket: Integer;
  ...
begin
  ...
  s := Ctx.GetType(TTestClass).GetField('test_list').FieldType.ToString; // returns 'TList<System.string>'
  OpenBracket := Pos('<', s);
  CloseBracket := PosEx('>', s, OpenBracket+1);
  s := Copy(s, OpenBracket+1, CloseBracket-OpenBracket-1); // returns 'System.string'
  // if multiple Generic parameters are present, they will be separated by commas...
  ...
end;

Once you have extracted the Generic parameter as a string, you can use TRttiContext.FindType() if you need to access the RTTI for that type.

With that said, the following code provides a bunch of RTTI helpers:

TRttiTypeHelper
GetGenericArguments()
TRttiType
TRttiTypeHelper = class helper for TRttiType
...
public 
  ...
  function GetGenericArguments: TArray<TRttiType>;
  ...
end;

Internally, GetGenericArguments() uses the same technique I mention above. With it, you can do this instead:

uses
  ..., System.Rtti, DSharp.Core.Reflection;

var
  Ctx: TRttiContext;
  arr: TArray<TRttiType>;
  typ: TRttiType;
  s: string;
  ...
begin
  ...
  arr := Ctx.GetType(TTestClass).GetField('test_list').FieldType.GetGenericArguments;
  typ := arr[0]; // returns RTTI for System.String
  s := typ.ToString; // returns 'System.string'
  ...
end;

Thanks for this solid reply, but before I accept it as a final answer, could you please explain to me how the .ToString() method of the TRttiType instance for the test_list field obviously has access to this information when it prints the full string that you advise me to manually parse? The correct answer would in that case seem to be that there does exist RTTI information about this, although it's not accessible through the defined Delphi RTTI methods?

Also, while researching this myself in parallel, I found the TRttiEnumerationType which seems to be very promising for my objective with its .UnderlyingType property. Could you (or anyone else) possibly comment on that? Unfortunately I'm currently having some other problems with that solution, as described in the following other question: stackoverflow.com/questions/28922600/

TRttiType.ToString() simply returns the value of the TRttiNamedObject.Name property. TRttiType overrides the virtual GetName() property getter to retrieve the type name from the System.TypInfo RTTI pointed to by the TRttiType.Handle property (eg: PTypeInfo(Handle)^.Name). That Name value is generated by the compiler and stored as-is in the RTTI of the actual TList<String> class (not the TList<T> class, which has no RTTI of its own because it is not a concrete class). Again, there is no RTTI (from either the System.Rtti or System.TypInfo unit) for the Generic arguments

TRttiEnumerationType
.UnderlyingType

An enum is based on different types (byte, word, integer) depending on the number of elements, and compiler options. UnderlyingType tells you the base type. That has absolutely nothing to do with this discussion about Generics RTTI. And no, the documentation does not contradict my statement, it agrees with it. TList<T> itself does not have its own RTTI, but TList<String> (a concrete instantiation of TList<T>) does. Information about Generic parameters and their types is not stored in an instantiated type's RTTI. You have to hunt for it manually, as I explained.

generics - How can I get the sub-item type of a TObjectList purely ...

delphi generics rtti tobjectlist
Rectangle 27 1

Try using this preg_match_all("/\r?\n|\r){3,}/", $value); It means that \r\n or \n, or \r (which are in brackets) should appear three or more times.

Most of yours tries match \r\n, or \r, or tree times \n

That's the third permutation I tried (see above) - it puzzlingly returns one match to the form submission.

Then, I'm pretty sure that the issue is in the $value string because "Test Test" contains only 10 characters. I think another two may be line breaks at the end of it.

Regex engines will try to match that even if it has to divide up invalid line breaks. So, (\r\n|\r|\n){3,} matches 0x0d0x0a0x0d0x0a which is only 2 valid line breaks.

php - Regular expression preg_match_all test to capture more than two ...

php regex
Rectangle 27 1

With your particular example, I expect if you first solved the problem of "make this code readable", fitting in 79 characters would come naturally.

(self.caller.parent.parent
 .parent.caller.parent.bar
 .ids.actionview.remove_widget(
    self.caller.parent.parent
    .parent.caller.parent
    .bar.ids.actionview.startbutton)
)

Thanks this works; as for readability, I agree this is really not ideal. Unfortunately I have deeply nested objects and the kivy environment I'm using (as far as I can tell) doesn't allow you to access objects by id unless they were defined in a static way within the .kv file. I'm creating and destroying objects dynamically and thus have to address them directly within the hierarchy.

Still, off the top of my head, I can't even see how a malicious library would prevent you from something like mybar = self.caller.parent.parent.parent.caller.parent.bar and then using mybar from there.

How to break long lines in python that have no brackets or operators? ...

python
Rectangle 27 1

With your particular example, I expect if you first solved the problem of "make this code readable", fitting in 79 characters would come naturally.

(self.caller.parent.parent
 .parent.caller.parent.bar
 .ids.actionview.remove_widget(
    self.caller.parent.parent
    .parent.caller.parent
    .bar.ids.actionview.startbutton)
)

Thanks this works; as for readability, I agree this is really not ideal. Unfortunately I have deeply nested objects and the kivy environment I'm using (as far as I can tell) doesn't allow you to access objects by id unless they were defined in a static way within the .kv file. I'm creating and destroying objects dynamically and thus have to address them directly within the hierarchy.

Still, off the top of my head, I can't even see how a malicious library would prevent you from something like mybar = self.caller.parent.parent.parent.caller.parent.bar and then using mybar from there.

How to break long lines in python that have no brackets or operators? ...

python
Rectangle 27 1

Another gotcha here wasted some of my time, so I thought I would pass along the tip. I had a hidden field I gave an id that had . and [] brackets in the name (due to use with struts2) and the selector $("#model.thefield[0]") would not find my hidden field. Renaming the id to not use the periods and brackets caused the selector to begin working. So in the end I ended up with an id of model_the_field_0 instead and the selector worked fine.

That's because your selector $("#model.thefield[0]") is being interpreted as: an element with id equal to model, a css class of thefield and some attribute called 0... If you want to use those characters in your id use the approach suggested by Chuck Callebs in his answer. In HTML5 the id may be any string that is not empty and does not contain any space characters (reference).

Set value of hidden field in a form using jQuery's ".val()" doesn't wo...

jquery set hidden-fields
Rectangle 27 1

Another gotcha here wasted some of my time, so I thought I would pass along the tip. I had a hidden field I gave an id that had . and [] brackets in the name (due to use with struts2) and the selector $("#model.thefield[0]") would not find my hidden field. Renaming the id to not use the periods and brackets caused the selector to begin working. So in the end I ended up with an id of model_the_field_0 instead and the selector worked fine.

That's because your selector $("#model.thefield[0]") is being interpreted as: an element with id equal to model, a css class of thefield and some attribute called 0... If you want to use those characters in your id use the approach suggested by Chuck Callebs in his answer. In HTML5 the id may be any string that is not empty and does not contain any space characters (reference).

Set value of hidden field in a form using jQuery's ".val()" doesn't wo...

jquery set hidden-fields
Rectangle 27 1

i have looked into the other answers, and a vital logic seems to be missing from them . ie, select everything between two CONSECUTIVE brackets,but NOT the brackets

\{([^{}]+)\}

javascript - Regex to get string between curly braces "{I want what's ...

javascript regex
Rectangle 27 1

Make sure all brackets are closed, also make sure your special characters in the URL such as & it converted into

XML containing link throws error in Visual Studio when running XSLT De...

xml visual-studio xslt
Rectangle 27 3

Works for me.Is it possible your ERRORLEVEL variable to be overwriten or your code to be in brackets block? try one of these:

sc query "serviceName" | findstr /i "RUNNING" && (
    echo serviceName is running.
    goto :skip_not_w
) 
echo serviceName is not running
:skip_not_w

The cited bug is for windows nt (is this your OS?) and should be fixed already...If your os is NT , you should parse the output of the command with FOR /F to see it contains RUNNING or use FINDSTR

windows - Check if service is running without using Find command - Sta...

windows batch-file cmd
Rectangle 27 1

You should not have brackets (parentheses) around the handler method so this:

AddHandler cameras(i).StreamGrabber.ImageGrabbed, AddressOf ImageGrabEvent

The sender object gives you the object that raised the event

Correct Answer! Had one more error: The Main Sub was declared as shared which also raised an error while declaring the AddHandler

vb.net - How to "AddHandler" trying to catch an event from an external...

vb.net event-handling addhandler raiseevent