Search Results

Search found 2455 results on 99 pages for 'lambda expressions'.

Page 73/99 | < Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >

  • Using Where method in Linq 2 Entities with OR clause.

    - by Dani
    I want to use Where method in Linq 2 entities that will be equal to this userRepository.Users.Where(u=>u.RoleID == 1 || u=>u.RoldID == 2).Select(o => new SelectListItem { Text = o.Role.RoleName, Value = o.RoleID.ToString() }).ToList(); The problem of course is in Where(u=u.RoleID == 1 || u=u.RoldID == 2) The problem is that I don't know how to use WHERE method with OR inside the WHERE clause. any ideas (the code above will not compile of-course b/c of the lambda expression. userRepository.Users returns an list of Users entities. I guess that and can be done using concatenation of .Where().Where() but I need an OR.

    Read the article

  • Complex regular expression

    - by Jose3d
    Hello, i will like to capture a substring part of a text choosing the number of characters but if any word is cut then get until de last blank. As example if this is the text: "This is an example of text lorem ipsum, etc..." and i would like to get for instance 12 characters that are: "This is an e". In this case example is cutted, then i would like to get "This is an". Its possible do this with Regular Expressions? Thanks in advance. Jose

    Read the article

  • Show me some cool python list comprehensions

    - by christangrant
    One of the major strengths of python and a few other (functional) programming languages are the list comprehension. They allow programmers to write complex expressions in 1 line. They may be confusing at first but if one gets used to the syntax, it is much better than nested complicated for loops. With that said, please share with me some of the coolest uses of list comprehensions. (By cool, I just mean useful) It could be for some programming contest, or a production system. For example: To do the transpose of a matrix mat >>> mat = [ ... [1, 2, 3], ... [4, 5, 6], ... [7, 8, 9], ... ] >>> [[row[i] for row in mat] for i in [0, 1, 2]] [[1, 4, 7], [2, 5, 8], [3, 6, 9]] Please include a description of the expression and where it was used (if possible).

    Read the article

  • Express XPath as an expression tree

    - by 47d_
    If I have an XPath query like NodeA/NodeB[@WIDTH and not(@WIDTH="20")] | NodeC[@WIDTH and not(@WIDTH="20")]/NodeD Is there any API available to visualize this XPath query as a stack of atomic expressions, something like (following is generic) Get results of NodeA, call it "first set" Get results of NodeB from "first set" Filter where [@WIDTH and not(@WIDTH="20")] Filter NodeD, call this "node d for B" Get results of NodeC from "first set" Filter where [@WIDTH and not(@WIDTH="20")] Filter NodeD, call this "node d for C" Combine "node d for B" and "node d for C" I am trying to see if we can convert the XPath expression into custom expression which is close to english and vice versa. If no API is available, what would be the best approach? Thanks in advance.

    Read the article

  • What should I know about Python to identify comments in different source files?

    - by Can't Tell
    I have a need to identify comments in different kinds of source files in a given directory. ( For example java,XML, JavaScript, bash). I have decided to do this using Python (as an attempt to learn Python). The questions I have are 1) What should I know about python to get this done? ( I have an idea that Regular Expressions will be useful but are there alternatives/other modules that will be useful? Libraries that I can use to get this done?) 2) Is Python a good choice for such a task? Will some other language make this easier to accomplish?

    Read the article

  • How do I perform a dynamic select in Linq?

    - by Matt Mangold
    I am trying to figure out how to dynamically specify the properties for my select clause in a linq query. Lets say I have a collection of employee objects. At run time, the end user will be specifying which properties they would like to see for those employees, so I need to be able to dynamically construct my Linq select clause. I have used the dynamic Linq library, but I prefer not to use that, because it requires me to build a string to pass to the select method. I'd like to understand how to do this via Expressions.

    Read the article

  • Javascript: parseInt() with trailing characters

    - by chris_l
    parseInt("7em", 10); returns 7 in all browsers I tested [*]. But can I rely on this? The reason I ask is, that I want to perform some calculations based on em, like /* elem1.style.top uses em units */ elem2.style.top = parseInt(elem1.style.top, 10) + 1 + "em"; I could do this with regular expressions, but parseInt is easier to use, and probably a bit faster. Or is there another solution (maybe using jQuery)? [*] Tested so far on: IE 6, IE 8, Safari 4, Firefox 3.6, Opera 10.5

    Read the article

  • jQuery. Treat a string as a HTML document?

    - by James Jeffery
    I'm not sure if I worded the title correctly. Basically is it possible to treat a string as HTML as if it was on the page? So I can use $("#elem") and all the other jQuery functions? The HTML is loaded into a string from an ajax request and stored in a string. Instead of using regular expressions to access the data needed is it possible to use jQuery functions? ajaxTextResponse.$("#telephone"); I know the above won't work, but you see what I am getting at. Thanks

    Read the article

  • Java String replaceAll with conditions

    - by user1483570
    I am not good in regular expressions and I need help in replacing the string. String str = "Name_XYZ_"; str = "XYZ_NAME_"; So how can I replace "Name_" or "_NAME_" from above two strings with empty string? The conditions are "Name" can be in any case and it can be at index 0 or at any index but preceded by "_". So far I tried, String replacedString = str.replaceAll("(?i)Name_", ""); // This is not correct. This is not the homework. I am working on XML file that needs such kind of processing. Please help. Thank you.

    Read the article

  • Not a statement?

    - by abelenky
    I have a simple little code fragment that is frustrating me: HashSet<long> groupUIDs = new HashSet<long>(); groupUIDs.Add(uid)? unique++ : dupes++; At compile time, it generates the error: Only assignment, call, increment, decrement, and new object expressions can be used as a statement HashSet.Add is documented to return a bool, so the ternary (?) operator should work, and this looks like a completely legitimate way to track the number of unique and duplicate items I add to a hash-set. When I reformat it as a if-then-else, it works fine. Can anyone explain the error, and if there is a way to do this as a simple ternary operator?

    Read the article

  • Python sort 2-D list by time string

    - by Mark Kennedy
    How do I sort a multi dimensional list like this based on a time string? The sublists can be of different sizes (i.e. 4 and 5, here) I want to sort by comparing the first time string in each sublist (sublist[-4]) x = (['1513', '08:19PM', '10:21PM', 1, 4], ['1290', '09:45PM', '11:43PM', 1, 4], ['0690', '07:25AM', '09:19AM', 1, 4], ['0201', '08:50AM', '10:50AM', 1, 4], ['1166', '04:35PM', '06:36PM', 1, 4], ['0845', '05:40PM', '07:44PM', 1, 4], ['1267', '07:05PM', '09:07PM', 1, 4], ['1513', '08:19PM', '10:21PM', 1, 4], ['1290', '09:45PM', '11:43PM', 1, 4], ['8772', '0159', '12:33PM', '02:43PM', 1, 5], ['0888', '0570', '09:42PM', '12:20AM', 1, 5], ['2086', '2231', '04:10PM', '06:20PM', 1, 5]) The sorted result would be sortedX = (['0690', '07:25AM', '09:19AM', 1, 4], ['0201', '08:50AM', '10:50AM', 1, 4], ['1166', '04:35PM', '06:36PM', 1, 4], ['0845', '05:40PM', '07:44PM', 1, 4], ['1267', '07:05PM', '09:07PM', 1, 4], ['1513', '08:19PM', '10:21PM', 1, 4], ['1513', '08:19PM', '10:21PM', 1, 4], ['1290', '09:45PM', '11:43PM', 1, 4], ['1290', '09:45PM', '11:43PM', 1, 4], ['8772', '0159', '12:33PM', '02:43PM', 1, 5], ['2086', '2231', '04:10PM', '06:20PM', 1, 5], ['0888', '0570', '09:42PM', '12:20AM', 1, 5]) I tried the following: sortedX = sorted(x, key=lambda k : k[-4]) #k[-4] is the first time string and it works but it doesn't respect the sublist size ordering

    Read the article

  • Efficient way to organise data file in columns with Python

    - by user1700959
    I'm getting an output data file of a program which looks like this, with more than one line for each time step: 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 7.9819E-06 1.7724E-02 2.3383E-02 3.0048E-02 3.8603E-02 4.9581E-02 5.6635E-02 4.9991E-02 3.9052E-02 3.0399E-02 .... I want to arrange it in ten columns I have made a Python script, using regular expressions to delete \n in the proper lines, but I think that there should be a simpler more elegant way to do it, here is my script: import re with open('inputfile', encoding='utf-8') as file1: datai=file1.read() dataf=re.sub(r'(?P<nomb>( \d\.\d\d\d\dE.\d\d){8})\n','\g<nomb>',datai) with open('result.txt',mode='w',encoding='utf-8') as resultfile: resultfile.write(datof) Thanks in advance

    Read the article

  • mootools: $ not defined

    - by eaigner
    I've strange error i don't understand. I'm just moving my code from jQuery over to Mootools because it's much cleaner than the jQuery mess. Now when i use the $$('div.canvas') in mootools i get the correct element. When i try $(document).getElement('div.canvas') it tells me that $ is not defined. How can $$ and all helper functions like $lambda etc. be defined but not $? Has something changed there from 1.1 to 1.2 and the docs are not updated yet?

    Read the article

  • mysterious difference between rake test and ruby

    - by standup75
    Here is the mysterious: I have a scope which looks like this (in Image.rb) scope :moderate_all, delegates.where("moderation_flag = #{$moderation_flags[:not_moderated]}") Note that delegates is another scope that I am defining before moderate_all When I leave it like this, I can run my test that checks if an image has been "checked-out" it is not available anymore. I don't put the code of the test, because it does not matter actually. With this code, when I run "rake test" it fails, but if I do "ruby test/unit/image_test.rb" it works! I was thinking I am starting to have a bad day. Then I tried scope :moderate_all, lambda { delegates.where("moderation_flag = #{$moderation_flags[:not_moderated]}") } And "rake test" passes! So my problem is solved, but why?

    Read the article

  • Maven: Variables are not replaced in installed and deployed POM

    - by mmuthu
    We have been trying to migrate our multi-module projects to maven. I have been struggling with the maven install plugin bug "http://jira.codehaus.org/browse/MNG-2971". I have written a Java program which can find and replace the expressions using my settings.xml and POM in my local repository view. As a result all of my parent POM's are having a additional phase in the build process. What i'm doing is that i have attached a goal which will run my Java program during "validate" phase. I think this is a not a good idea instead i would have asked individuals to run the program on their local repository on their own. What i'm asking here is that the best way to work around the "install" plugin issue (MNG-2971). I searched through the net but i could not locate such work around.

    Read the article

  • Java splitting string by custom regex match

    - by slikz
    I am completely new to regular expressions so I'm looking for a bit of help here. I am compiling under JDK 1.5 Take this line as an example that I read from standard input: ab:Some string po:bubblegum What I would like to do is split by the two characters and colon. That is, once the line is split and put into a string array, these should be the terms: ab:Some string po:bubblegum I have this regex right now: String[] split = input.split("[..:]"); This splits at the semicolon; what I would like is for it to match two characters and a semicolon, but split at the space before that starts. Is this even possible? Here is the output from the string array: ab Some String po bubblegum I've read about Pattern.compile() as well. Is this something I should be considering?

    Read the article

  • Replace html tag with a certain class

    - by fire
    I am looking for suitable replacement code that allows me replace the content inside of any HTML tag that has a certain class e.g. $class = "blah"; $content = "new content"; $html = '<div class="blah">hello world</div>'; // code to replace, $html now looks like: // <div class="blah">new content</div> Bare in mind that: It wont necessarily be a div, it could be <h2 class="blah"> The class can have more than one class and still needs to be replaced e.g. <div class="foo blah green">hello world</div> I am thinking regular expressions should be able to do this, if not I am open to other suggestions such as using the DOM class (although I would rather avoid this if possible because it has to be PHP4 compatible).

    Read the article

  • Java or C# + XNA for some simple animations?

    - by lala
    I want to make a program that will involve some faces with various facial expressions. They will change from one facial expression to another based on their "mood" as influenced by user input. I know some java but I have done pretty much nothing with graphics. A friend tells me that it will be easier to do this in C# with XNA than to do it in java. I have about a month to do this, so I was hoping you folks would help me make a decision. Would I be better off figuring out how to do this in java, or learning C# and XNA and doing it in C#? Is it so much easier to do this in C# that it would be quicker to learn C# than to struggle with doing it in java? Will it probably come out looking much better if it is in C#?

    Read the article

  • Regular Expression to Match All Characters after another Regex Match

    - by Anthony Wood
    I know this may sound a little confusing, so I am open to suggestions on renaming the title. Basically I have string such as C:...\Downloads\Folder\SubFolder\SubSubFolder. and I want to return the SubFolder and SubSubFolder only. So far, my Regex looks like (?=\\Downloads\\.*?\\).* which matches Downloads\Folder\SubFolder\SubSubFolder. Does anybody have any Ideas what I am missing???? All the solutions below seem to work (except if you didn't know "Folder"). Potentially a bug with the tool I was using to test the regular expressions.

    Read the article

  • Regex to match a Java method signature

    - by nitesh
    I am having this particular requirement where a method has to be identified by different regular expressions for different components. For example, there need to be a regex for return parameter, one for method name, one for argument type and one for argument name. I was able to come up with an expression till this step as follows - ([^,]+) ([^,]+)\((([^,]+) ([^,]+))\) It works well for a method signature like - ReturnType foo(Arg parameter) The regular expression identifies ReturnType, foo, Arg and parameter separately. Now the problem is that a method can have no/one/multiple arguments separated by commas. I am not able to get a repeating expression for this. Help will be appreciated.

    Read the article

  • How do I use the orientationchange in jQuery Mobile when working with height?

    - by stucktryingtofigurethisout
    In jQuery Mobile, I am trying to adjust the height of an image to the height of the window. The height of the window depends on the orientation of the device, but I found out that whenever I change the orientation, the height of the window that is plugged into the expressions for the height of the image is the height of the window BEFORE the orientation change! So, how do I make it so it picks up the height of the window AFTER the orientation change and then uses this new value to adjust the image height? For the code I have $(window).bind('orientationchange',function(e){ if(window.orientation == 0) { $('img').css('width') = $(window).height()*.5; } else { $('img').css('width') = $(window).height()*.6; } });

    Read the article

  • Adding items to dictionary if condition is true, else dont - python

    - by CodeTalk
    I'm trying to take an existing process: if self.path_object is not None: dictpath = {} for path in self.path_object: self.params = path.pathval.split("?")[0] self.params = path.pathval.split("&", 2) if path.pathval.contains(self.params): out = list(map(lambda v: v.split("=")[0] +"=" + str(self.fuzz_vectors), self.params)) else: pass dictpath[path] = out print dictpath I added the sub-if/else block in, but it is failing, stating: AttributeError: 'unicode' object has no attribute 'contains' on the if block . How can I fix it? I'm simply trying to do: if the path.pathval has either ? or & in it: add to dictionary else: pass #forget about it. Thanks!

    Read the article

  • Why is my regex so much slower compiled than interpreted ?

    - by miket2e
    I have a large and complex C# regex that runs OK when interpreted, but is a bit slow. I'm trying to speed this up by setting RegexOptions.Compiled, and this seems to take about 30 seconds for the first time and instantly after that. I'm trying to negate this by compiling the regex to an assembly first, so my app can be as fast as possible. My problem is when the compiling delay takes place: Regex myComplexRegex = new Regex(regexText, RegexOptions.Compiled); MatchCollection matches = myComplexRegex.Matches(searchText); foreach (Match match in matches) // <--- when the one-time long delay kicks in { } This is making compiling to an assembly basically useless, as I still get the delay on the first foreach call. What I want is for all the compiling delay to be done in advance when I compile to the assembly, not when the user runs the app. Where am I going wrong ? (The code I'm using to compile to an assembly is similar to http://www.dijksterhuis.org/regular-expressions-advanced/ , if that's relevant ).

    Read the article

  • Run a site on Scheme

    - by Lajla
    I can't find this on Google (so maybe it doesn't exist), but I basically'd like to install something on a web server such that I can run a site on Scheme, PHP is starting to annoy me, I want to get rid off it, what I want is: Run Scheme sources towards UTF-8 output (duh) Support for SXML, SXLT et cetera, I plan to compose the damned thing in SXML and - to normal representation on at the end. Ability to read other files from the server, write them, set permissions et cetera Also some things to for instance determine the filesize of files, height of images, mime-types and all that mumbo-jumbo (optionally) connect to a database, but for what I want to do storing the entire database in S-expressions itself is feasible enough I don't need any fancy libraries and other things that come with it like CMS'es and what-not, except the support for SXML but I'm sure I can just find a lib for that anyway that I can load.

    Read the article

  • using regular expression / Remove special characters with linq to sql

    - by Prasad
    How can i use regular expressions with linq to sql in the asp.net mvc(C#) application? The columns in my MSSQL table (Products) has some special characters like (, - % ',.....). While searching for a product i need to search without that special chareters. For ex.: I have a product say (ABC-Camp's / One), when i search for "abccamp", it should pull the product. I am trying the query like: from p in _context.pu_Products where p.User_Id == userId && p.Is_Deleted == false && p.Product_Name.ToLower().Contains(text.ToLower()) select new Product { ProductId = p.Product_Id, ProductName = p.Product_Name.Replace("’", "").Replace("\"", ""), RetailPrice = p.Retail_Price ?? 0M, LotSize = p.Lot_Size > 0 ? p.Lot_Size ?? 1 : 1, QuantityInHand = p.Quantity_In_Hand ?? 0 } But i need to search without any special characters...

    Read the article

< Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >