Search Results

Search found 2819 results on 113 pages for 'conditional expressions'.

Page 82/113 | < Previous Page | 78 79 80 81 82 83 84 85 86 87 88 89  | Next Page >

  • 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

  • What is the term(s) used to describe programming language syntax?

    - by Mr Roys
    Is there an exact/correct term to describe this difference between the syntax/constructs of programming langauges e.g VB6 with its (if ... else ... endif) and C# with its curly braces for conditional statements. I'm using VB6 syntax and C# as examples since I'm more familiar with their syntax. For example, Visual Basic 6's syntax uses a more verbose, natural language like structure. If (id = 0) Then id = MyObject.Add(Me) Else Call MyObject.Update(Me) End If while C# has more concise syntax like: if (id == 0) { id = MyObject.Add(this); } else { MyObject.Update(this); } Conciseness? Natural languageness? Or is there a more "scientific" word for describing syntax?

    Read the article

  • Modulation of adding new Strings -> Method calls.

    - by guesswork
    If I have a program that does the following: if(input=='abc'){do x} if(input=='def'){do y} In the future, I may want to add another piece of code like so: if(input=='ghy'){do x} As you can see, I am adding a new 'if' statement for a different conditional BUT using the SAME function X. The code in future has potential to have lots of different IF statements (or switches) all of which are comparing a string vs a string and then performing a function. Considering the future expansion, I was wondering if there is a possible 'neater', 'modular' way of achieving the same results. It's a shame I can't combine the String with a Method call in a hashtable (String, method) in Java. That way I could just store any new procedures inside a hashtable and grab the relevant method for that String. Any ideas? Thank you

    Read the article

  • How to use #ifdef entities as part of functions in header files

    - by Crazyjavahacking
    I would like to ask if it is possible to use the entities defined in #ifdef block in header files. To be clear, I have following code: #ifdef #include <winsock2.h> #define SOCKET_HANDLE SOCKET #define CONNECTION_HANDLE SOCKET #endif SOCKET_HANDLE createServerSocket(const char* hostAddress, short port); I am Java developer and this seems completely fine for me. However compiler has a problem with this. Can you explain why is that code a problem? Also how can I force to compile it. (The idea is to have generic interface and conditional compilation to determine real types according to running platform at compile time.) Thanks

    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

  • 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

  • XCode iPhone OS Deployment Target Tool

    - by Trah Divad
    Problem I'm currently stuck trying to figure out what "iPhone OS Deployment Target" setting to use. I do not want to write conditional code right now, so I'd like the lowest version that runs my application fine. At first I thought it would be 2.0 as I wasn't using any 3.0 features, but then i realized that AVAudioRecorder is a 3.0 API. I don't want to be manually checking EVERY function I use in the documentation. Question Is there a tool that will check the OS availability of each functions you call in your code to figure out what the Deployment Target should be? That tool could be a good old compiler, but the latest version of the iPhone SDK does not come with the PRE-3.0 SDKs.

    Read the article

  • Jquery/CSS help needed to make fallback for IE and older browsers

    - by matt_50
    Wondering if any of you can help me: I've made a signup modal that uses a CSS transform to switch between two methods of signing up. I've decided to try a 'card flip' type effect. Have a look at this JSfiddle in any browser that supports CSS 3D transforms - click the 'old fashioned way' text to 'flip' the modal (simplified for demo purposes): http://jsfiddle.net/voodoo6/cnTMz/8/ Then take a look in IE8/9 - as the 'back' is taller than the front and IE does;t support 'backface-visibility: hidden;' the reverse can be seen below the front. I've been trying to use JQuery and conditional CSS to 'display:none' the 'back' on load in IE (and older browsers), then add a 'display:block;' class to show it on click, problem is, I'm a JQuery beginner and have been struggling to get it to work! Not even sure if this is the best approach? Can anybody suggest an approach that would get this working in less-capable browsers? Thanks for any advice..

    Read the article

  • DropDownList always does full-page postback, the first time it fires.

    - by CodexArcanum
    I have an ASP.NET page using the AJAX library. There is a dropdownlist inside an UpdatePanel, which on index changing is supposed to update a different UpdatePanel to modify a grid control. But after the page first comes up, and you adjust the ddl, the entire page postbacks, followed by a (correct) partial postback. After this one time, every other usage of the ddl performs correctly, trigger partial postbacks. Both the panel and the ddl are being added from code. The UP is Conditional updates and ChildrenAsTriggers = true. The dropdownlist is AutoPostBack true and has an event set up on SelectedIndexChanged. So what is going on? I've tried adjusting every setting I can think of and still the page completely refreshes once, then works fine after that.

    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

  • 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

  • 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

  • Displaying objects based on if a user is logged in or not

    - by MaxMackie
    I'm learning about PHP sessions for user authentication on my website. I know how to restrict the viewing of a complete page using sessions (simply check if the 'uid' session variable is set and if it is, show content, if not redirect to an error). However I'm trying to figure out the best way to selectively show and hide different objects (div, text, images) based on if a user is logged in or not. Is it as simple as checking for the 'uid' session variable and displaying based on if it set or not? Is there a more efficient way of doing this id there are a lot of conditional elements on a page?

    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

  • 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

  • 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

  • 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

  • Why is the value of __name__ changing after assignment to sys.modules[__name__]?

    - by martineau
    While trying to do something similar to what's in the ActiveState recipe titled Constants in Python by Alex Martelli, I ran into an unexpected side-effect that assigning a class instance to an entry in sys.modules apparently has in Python 2.7 -- namely that doing so apparent changes the value of __name__ to None as illustrated in the following code fragment: class _test(object): pass import sys print '__name__: %r' % __name__ # __name__: '__main__' sys.modules[__name__] = _test() print '__name__: %r' % __name__ # __name__: None if __name__ == '__main__': # never executes... import test print "done" I'd like to understand why this is happening. I don't believe it was that way in Python 2.6 and earlier versions since I have some older code where apparently the if __name__ == '__main__': conditional worked as expected following the assignment (but no longer does). FWIW, I also noticed that the name _class is getting rebound from a class object to None, too, after the assignment. Also seems odd to me that they're being rebound to 'None' rather than disappearing altogether... Update: I'd like to add that any workarounds for achieving the effect of if __name__ == '__main__':, given what happens would be greatly appreciated. TIA!

    Read the article

  • how to call a php class function directly using ajax?

    - by payling
    Is it possible to call a php class function DIRECTLY using ajax? Something like below... except ajax... myclass::myfunction(); I've been using the jquery library to work with AJAX. $.get('control.php', {func: funcName, arg1: arg1}); The above is similar to what I'm trying to achieve MINUS the control.php; I'm not sure if this is even possible, but I just thought it would be nice to skip the landing page (control.php) that recieves the funcName. I have a bunch of conditional statements that sort out what class function to run based on the funcName recieved. It seems kind of silly to do this, to have a separate page just to handle function calls. Is there a better way?

    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 | 78 79 80 81 82 83 84 85 86 87 88 89  | Next Page >