Search Results

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

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

  • 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

  • Performing multiple operations if condition is satisfied in ternary operator in linq

    - by user1575914
    I am a beginner in LINQ.I want to perform some conditional operation lik follows, (from emp in Employees let DOB=emp.BirthDate.GetValueOrDefault() let year=DOB.Year let month=DOB.Month let EmpAgeInYearsToday=DateTime.Now.Year-year let EmpAgeInMonthToday=DateTime.Now.Month-month let temp_year=(EmpAgeInYearsToday-1) let ExactNoOfMonths_temp=EmpAgeInMonthToday<0?temp_year:EmpAgeInMonthToday let ExactNoOfMonths=EmpAgeInMonthToday<0?EmpAgeInMonthToday+12&temp_year:EmpAgeInMonthToday select new{emp.EmployeeID,DOB, EmployeeAgeToday=EmpAgeInYearsToday+" Years "+ExactNoOfMonths+" Months ").Dump(); Here, let ExactNoOfMonths=EmpAgeInMonthToday<0?EmpAgeInMonthToday+12&temp_year:EmpAgeInMonthToday This part is not working. How to achieve this? How to perform multiple operations when the condition is satisfied?

    Read the article

  • In .NET MVC, is there an easy way to check if I'm on the home page?

    - by Hairgami_Master
    I need to take a particular action if a user logs in from the home page. In my LogOnModel, I have a hidden field: @Html.Hidden("returnUrl", Request.Url.AbsoluteUri) In my Controller, I need to check if that value is the Home page or not. In the example below, I'm checking to see if the user is on a particular page ("Account/ResetPassword"). Is there a way to check to see if they're on the home page without resorting to regular expressions? [HttpPost] public ActionResult LogOnInt(LogOnModel model) { if (model.returnUrl.Contains("/Account/ResetPassword")) { return Json(new { redirectToUrl = @Url.Action("Index","Home")}); } Any ideas? A million thanks!

    Read the article

  • Pulling international street addresses / phone numbers from free-form text

    - by spitzanator
    Hey, folks. I'm looking for some regular expressions to help grab street addresses and phone numbers from free-form text (a la Gmail). Given some text: "John, I went to the store today, and it was awesome! Did you hear that they moved to 500 Green St.? ... Give me a call at +14252425424 when you get a chance." I'd like to be able to pull out: 500 Green St. (recognized as a street address) +14252425424 (recognized as a phone number) What makes this problem easier is that I don't care about parsing text that gets pulled out. That is, I don't care that Green is the name of the road or that 425 is the area code. I just want to grab strings that "look like" addresses or telephone numbers. Unfortunately, this needs to work internationally, as best as possible. Anyone have any leads? Thanks!

    Read the article

  • Simple Search and Replace use of Regular Expression

    - by nunos
    So, I am adapting some code I found online to suit my needs. However, my set_pixel function has two more parameters. Since there are lots of calls to this function even doing a quick paste over would be very tedious. So, I thought this would be a good time for me to learn some simple regular expressions. So, I have calls of this type: set_pixel(arg1, arg2); which I want to change to something like: set_pixel(arg1, arg2, arg3, arg4); Note: arg1 and and 2 should be preserved, whereas arg3 and arg4 are most of the time the same. How can I achieve this?

    Read the article

  • Allow alphanumeric, punctuation, and spaces

    - by bccarlso
    I'm pretty new to regular expressions, and MAN do they give me a headache. They are so intimidating! For an email campaign I'm doing, a user will click a link out of the email with a few URL parameters filled in for them, to make filling out a form easier. I want to prevent any injection hacks or whatever it's called, but need to allow the $_GET parameters to be alphanumeric, have punctuation, and have spaces. If someone has a good method for this, I'd appreciate it, but right now I have: foreach($_GET as $m=>$n) { $get[$m] = preg_replace('(^[a-z0-9 \-\_\.]+)i',' ',$n); } I would like to be able to replace all characters NOT found with this regular expression, which I believe I use ?!, but I can't get that to work either. Any help in getting this to work would be appreciated!

    Read the article

  • How to write a regular expression for "everything between X and Y" for use with preg_replace

    - by pg
    I want to take a variable called $encoded_str and and remove cd1, CD1 and anything between the first 'l' and the last blank space. So for example "lp6 id4 STRINGcd1" would return "STRING". I'm using PHP 4 for now so I can't use str_ireplace, I have this: $encoded_str=str_replace('CD1','',$encoded_str); $encoded_str=str_replace('cd1','',$encoded_str); $encoded_str=preg_replace('X','',$encoded_str); I've RTFM for preg_replace but am a bit confused. What should I replace the X with and can you suggest a decent introductory primer for writing regular expressions?

    Read the article

  • Interesting or unique types encountered?

    - by user318904
    What is the most strange or unique type you have seen in a programming language? I was thinking the other day about a "random variable", ie whenever it is evaluated it yields a random value from some domain. It would require some runtime trickery. Also I bet there can be some interesting mapping of regular expressions into a type system. It does not necessarily have to be a built in or primitive type, but some random class that implements a domain specific type won't really be interesting just unique.

    Read the article

  • How do I delete an object from an Entity Framework model without first loading it?

    - by Tomas Lycken
    I am quite sure I've seen the answer to this question somewhere, but as I couldn't find it with a couple of searches on SO or google, I ask it again anyway... In Entity Framework, the only way to delete a data object seems to be MyEntityModel ent = new MyEntityModel(); ent.DeleteObject(theObjectToDelete); ent.SaveChanges(); However, this approach requires the object to be loaded to, in this case, the Controller first, just to delete it. Is there a way to delete a business object referencing only for instance its ID? If there is a smarter way using Linq or Lambda expressions, that is fine too. The main objective, though, is to avoid loading data just to delete it.

    Read the article

  • Is there a way to hide a row or column in excel without using VBA?

    - by AJ
    I know of several approaches using a macro (VBA) to show/hide columns and rows in Excel, but I cannot figure out or find a way to do this using either a formula or conditional formatting. Of particular interest is Excel 2007 - but I'd be curious to know if someone has managed to do it in any version of Excel. For those who want background, I have a spread of data with dates across the top and labels down the first column. I would like to specify a date window (on another sheet) as two cells with drop down dates (months) which would then show/hide the appropriate columns on the data sheet.

    Read the article

  • Interpreted languages: The higher-level the faster?

    - by immersion
    I have designed around 5 experimental languages and interpreters for them so far, for education, as a hobby and for fun. One thing I noticed: The assembly-like language featuring only subroutines and conditional jumps as structures was much slower than the high-level language featuring if, while and so on. I developed them both simultaneously and both were interpreted languages. I wrote the interpreters in C++ and I tried to optimize the code-execution part to be as fast as possible. My hypothesis: In almost all cases, performance of interpreted languages rises with their level (high/low). Am I basically right with this? (If not, why?)

    Read the article

  • Find Javascript Code inside String

    - by Ph.E
    Greetings friends, I am developing a web application that will allow the customer to enter a personalized message, which will then be converted to HTML. Well, the problem is that I can not allow the insertion of Javascript code. So I need a method that filters the text, searching for and remove it. I think the regular expressions to solve my problem, but I'm having difficulty building. Some of his friends could help me, or has already developed something for this. Thank you.

    Read the article

  • Eclipse: The icons in "Display View" are all greyed out

    - by Mark Silberbauer
    The discussion here describes the "display view" in eclipse which allows one to to quickly evaluate java expressions. The thing is, when I open the display view the icons remain greyed out and I can't execute anything. The only icon that isn't is "clear console". The odd thing is, alot of the screenshots on the web show the same behaviour but the people posting about the feature don't mentioned it. There aren't any options in the context sensitive menu either. I'm trying it on a java project. I've tried it in the debug view and I get the same issue. I'll provide a screenshot once my hosting is sorted. I'm using eclipse 3.4.

    Read the article

  • Why does this simple bash code give a syntax error?

    - by Tim
    I have the following bash code, which is copied and pasted from "bash cookbook" (1st edition): #!/bin/bash VERBOSE=0; if [[ $1 =-v ]] then VERBOSE=1; shift; fi When I run this (bash 4.0.33), I get the following syntax error: ./test.sh: line 4: conditional binary operator expected ./test.sh: line 4: syntax error near `=-v' ./test.sh: line 4: `if [[ $1 =-v ]]' Is this as simple as a misprint in the bash cookbook, or is there a version incompatibility or something else here? What would the most obvious fix be? I've tried various combinations of changing the operator, but I'm not really familiar with bash scripting.

    Read the article

  • c# short if statement not working with int? (int=null)

    - by kobe
    I am trying to shorten my code by using short-if: int? myInt=myTextBox.Text == "" ? null : Convert.ToInt32(myTextBox.Text); But I'm getting the following error: Type of conditional expression cannot be determined because there is no implicit conversion between '' and 'int' The following works: int? myInt; if (myTextBox.Text == "") //if no text in the box myInt=null; else myInt=Convert.ToInt32(myTextBox.Text); And if I replace the 'null' in integer (say '4') it also works: int? myInt=myTextBox.Text == "" ? 4: Convert.ToInt32(myTextBox.Text);

    Read the article

  • Replace String pattern in Java

    - by Hirantha
    I have the following string "value=\"\\d{4}((((0[1-9])|(1[0-2]))((0[1-9])|([12]\\d)|(3[01]))?)?|(\\-(((0[1-9])|(1[0-2]))(\\-((0[1-9])|([12]\\d)|(3[01])))?)?)?)d{4}" There I want to replace all the occurrences of "{" with NCHAR(0x7B) "}" with NCHAR(0x7D). An the content in-between "{ }" should remain unchanged: Ex: \\d{4} after replacing -> NCHAR(0x7B) 4 NCHAR(0x7D). Is there a way to do this using Regular Expressions in Java?. Anyway, this can be done processing the whole string using string operations.

    Read the article

  • Format decimal to currency, should be in cents for values $0 to $1

    - by Spongeboy
    I have a decimal variable which represents a donation amount. Currently I am displaying it on screen as a currency like so- DonationAmount.ToString("C"); This gives the following output (given a US locale) 1 -> $1.00 2 -> $2.00 0.5 -> $0.50 I am happy with the first two example, but want to have "0.5" show as "50c". My current solution is with a conditional- if (DonationAmount > 1) return (DonationAmount * 100m).ToString() + "c"; else return DonationAmount.ToString("C"); Is there a better way?

    Read the article

  • the correct actionscript to find if object already exists

    - by touB
    I have a Rect object that I'd like to create and set its properties only once. After that, I want to just modify its properties since it already exists. This is my general idea if(theRect == undefined){ Alert.show("creating"); var theRect:Rect = new Rect(); //then set properties addElement(theRect); //then add it using addElement because addChild() does not work } else { Alert.show("updating"); //no need to create it since it's already been created //just access and change the properties } I tried several ways and combinations for the if conditional check: if(theRect == undefined){ if(theRect == null){ declaring and not declaring `var theRect:Rect;` before the if check declaring and instantiating to null before the if check `var theRect:Rect = null;` but can't get the desired effect. Everytime this code block runs, and depending on which version I've used, it either gives me a "can't access null object" error or the if statement always evaluates to true and creates a new Rect object and I get the "creating" Alert. What's the right way of creating that Rect but only if doesn't exist?

    Read the article

  • regular expression for bit strings with even number of 1s

    - by equilibrium
    Let L= { w in (0+1)* | w has even number of 1s}, i.e. L is the set of all bit strings with even number of 1s. Which one of the regular expressions below represents L? A) (0*10*1)* B) 0*(10*10*)* C) 0*(10*1)* 0* D) 0*1(10*1)* 10* According to me option D is never correct because it does not represent the bit string with zero 1s. But what about the other options? We are concerned about the number of 1s(even or not) not the number of zeros doesn't matter. Then which is the correct option and why?

    Read the article

  • Notepad++ regular expression find and replace $_REQUEST with $_GET but a more secure

    - by David
    What I am doing is replacing, in a large program, all $_REQUEST['var'] and mysql_escape_string($_REQUEST['var']) with either the 1st or 2nd line below the dotted line. Now, I have figured out this much of the regular expression but I would like to make it simpler. Instead of having to run the top one first then the 2nd one I would like to just run one all together. I tried this but it did not work. (mysql_escape_string\()*$_REQUEST\[\'([^']*)\'\]\)(\)*) So below is what works but again have to do it twice. $_REQUEST\[\'([^']*)\'\] mysql_escape_string\($_REQUEST\[\'([^']*)\'\]\) (isset($_GET['\1'])?mysql_real_escape_string($_GET['\1']):false) (isset($_POST['\1'])?mysql_real_escape_string($_POST['\1']):false) ============================ Update: Yeah, after some research I figured out that Notepad++ does not support most regular expressions. I guess one additional step can not hurt a person. It's just laziness. *NOTE: BUT if anyone wants to try feel free to comment. At least it is just 2 steps and not 20.

    Read the article

  • How do I make a URL text a link?

    - by jpjp
    Say on Facebook or Twitter, when I type "www.google.com" and submit it, it becomes a link. How do I code this in PHP? Do I use regular expressions to get where the www starts and the .com ends? Is this how they do it? <?PHP //some regular expression to get www and .com part $link="<a href='$url'>$url</a>"; echo $link; ?> How do I write a regular expression to get the "www" and ".com" part? And for twitter's @obama, obama would become a link to obama's site. What regular expression do they use to get the text after the @ and before the space?

    Read the article

  • regular expression

    - by Altariste
    Hi, I need to find all invocations of some logging macros in the code. The macro invocation is of the form: DEBUG[1-5] ( "methodName: the logged message", arguments) But the new versions of the macros are prepending the name of the method automatically, so my task is to write a Python script that will remove the duplicate function names specified already by the programmer. I'm using the sub function from the re module. I plan to substitute the part indicated by || signs below : ||DEBUG[1-5] ("methodName: || the logged message", arguments) with simply DEBUG[1-5](" The problem is following: To find the expressions I want to substitute, I use the following regular expression: ((DEBUG | INFO | all other macros names )[1-5]*)\s*\(\"\w+: But it doesn't match the whole expression ( from DEBUG right to the colon ), but only the macro name, that is for example DEBUG5. Is my expression wrong or there is some quirk in the Python regex processing? ( maybe the fact that I use the DEBUG[1-5] as a subgroup has something to do with this? ) Help from anyone more knowledgable than me appreciated :).

    Read the article

  • Image equivalent of ActionLink in ASP.NET MVC

    - by Jason Whitehorn
    In ASP.NET MVC is there an equivalent of the Html.ActionLink helper for Img tags? I have a controller action that outputs a dynamically generated JPEG and I wanted to use the same Lambda expressions to link to it as I do HREFs using ActionLink. Alternatively, a helper that just gives the URL to a route (again specified using Lambdas) would also be acceptable. EDIT: I had originally specified that I was using Preview 5, however I see that a Beta has been released. So all-in-all the version number was an unneeded piece of info as I may be upgrading soon :-)

    Read the article

  • How can I use "IF statements" in a postgres trigger

    - by Dan B
    I have a trigger function that I only want to fire on certain instances of INSERTS, in this case, if do_backup = true. If it fires in all instances, I get an infinite loop. The logic seems pretty simple to me, and the rest of the function works. But the trigger function does not seem to register my conditional and always runs, even when backup = true. CREATE OR REPLACE FUNCTION table_styles_backup() RETURNS TRIGGER AS $table_styles_backup$ DECLARE ... do_backup boolean; BEGIN SELECT backup INTO do_backup FROM table_details WHERE id=NEW.table_meta_id; IF (do_backup = true) THEN ... INSERT INTO table_styles_versions ( ... ) VALUES ( ... ); END IF; RETURN NULL; END; $table_styles_backup$ LANGUAGE plpgsql; CREATE TRIGGER table_styles_backup AFTER INSERT ON table_styles FOR EACH ROW EXECUTE PROCEDURE table_styles_backup();

    Read the article

  • Replace the content of a 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

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