Search Results

Search found 2155 results on 87 pages for 'mathematical expressions'.

Page 1/87 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • If you had to reinvent a new syntax for regular expressions, what would it look like?

    - by Timwi
    Regular expressions as they are today are pretty much as concise and compact as they can be. Consequently, they are often criticised for being unreadable and hard to debug. If you had to reinvent a new syntax for regular expressions, what would it look like? Do you prefer the concise syntax they already have (or a different but similarly concise syntax)? If so, please justify why you think regular expressions deserve to be this concise, but your favourite programming language doesn’t (unless it’s Perl). Or do you think regular expressions should have a slightly more spaced-out syntax and look a bit more like operators and syntax elements normally do in programming languages? If so, provide examples of what you think the syntax should look like, and justify why it is better than the current syntax. Or do you think there shouldn’t even be a special syntax for regular expressions, and instead they should be constructed from syntax elements already present in the programming language? If so, give examples of a syntax that might be used to construct such regular expressions.

    Read the article

  • Using Find/Replace with regular expressions inside a SSIS package

    - by jamiet
    Another one of those might-be-useful-again-one-day-so-I’ll-share-it-in-a-blog-post blog posts I am currently working on a SQL Server Integration Services (SSIS) 2012 implementation where each package contains a parameter called ETLIfcHist_ID: During normal execution this will get altered when the package is executed from the Execute Package Task however we want to make sure that at deployment-time they all have a default value of –1. Of course, they tend to get changed during development so I wanted a way of easily changing them all back to the default value. Opening up each package in turn and editing them was an option but given that we have over 40 packages and we might want to carry out this reset fairly frequently I needed a more automated method so I turned to Visual Studio’s Find/Replace… feature Of course, we don’t know what value will be in that parameter so I can’t simply search for a particular value; hence I opted to use a regular expression to identify the value to be change. In the rest of this blog post I’ll explain how to do that. For demonstration purposes I have taken the contents of a .dtsx file and stripped out everything except the element containing the parameters (<DTS:PackageParameters>), if you want to play along at home you can copy-paste the XML document below into a new XML file and open it up in Visual Studio: <?xml version="1.0"?> <DTS:Executable xmlns:DTS="www.microsoft.com/SqlServer/Dts">   <DTS:PackageParameters>     <DTS:PackageParameter       DTS:CreationName=""       DTS:DataType="3"       DTS:Description="InterfaceHistory_ID: used for Lineage"       DTS:DTSID="{635616DB-EEEE-45C8-89AA-713E25846C7E}"       DTS:ObjectName="ETLIfcHist_ID">       <DTS:Property         DTS:DataType="3"         DTS:Name="ParameterValue">VALUE_TO_BE_CHANGED</DTS:Property>     </DTS:PackageParameter>     <DTS:PackageParameter       DTS:CreationName=""       DTS:DataType="3"       DTS:Description="Some other description"       DTS:DTSID="{635616DB-EEEE-45C8-89AA-713E25845C7E}"       DTS:ObjectName="SomeOtherObjectName">       <DTS:Property         DTS:DataType="3"         DTS:Name="ParameterValue">SomeOtherValue</DTS:Property>     </DTS:PackageParameter>   </DTS:PackageParameters> </DTS:Executable> We are trying to identify the value of the parameter whose name is ETLIfcHist_ID – notice that in the XML document above that value is VALUE_TO_BE_CHANGED. The following regular expression will find the appropriate portion of the XML document: {\<DTS\:PackageParameter[\n ]*DTS\:CreationName="[A-Za-z0-9\:_\{\}- ]*"[\n ]*DTS\:DataType="[A-Za-z0-9\:_\{\}- ]*"[\n ]*DTS\:Description="[A-Za-z0-9\:_\{\}- ]*"[\n ]*DTS\:DTSID="[A-Za-z0-9\:_\{\}- ]*"[\n ]*DTS\:ObjectName="ETLIfcHist_ID"\>[\n ]*\<DTS\:Property[\n ]*DTS\:DataType="[A-Za-z0-9\:_\{\}- ]*"[\n ]*DTS\:Name="ParameterValue"\>}[A-Za-z0-9\:_\{\}- ]*{\<\/DTS\:Property\>} I have highlighted the name of the parameter that we’re looking for. I have also highlighted two portions identified by pairs of curly braces “{…}”; these are important because they pick out the two portions either side of the value I want to replace, in other words the portions highlighted here: <DTS:PackageParameters>     <DTS:PackageParameter       DTS:CreationName=""       DTS:DataType="3"       DTS:Description="InterfaceHistory_ID: used for Lineage"       DTS:DTSID="{635616DB-EEEE-45C8-89AA-713E25846C7E}"       DTS:ObjectName="ETLIfcHist_ID">       <DTS:Property         DTS:DataType="3"         DTS:Name="ParameterValue">VALUE_TO_BE_CHANGED</DTS:Property>     </DTS:PackageParameter> Those sections in the curly braces are termed tag expressions and can be identified in the replace expression using a backslash and a number identifying which tag expression you’re referring to according to its ordinal position. Hence, our replace expression is simply: \1-1\2 We’re saying the portion of our file identified by the regular expression should be replaced by the first curly brace section, then the literal –1, then the second curly brace section. Make sense? Give it a go yourself by plugging those two expressions into Visual Studio’s Find and Replace dialog. If you set it to look in “All Open Documents” then you can open up the code-behind of all your packages and change all of them at once. The Find and Replace dialog will look like this: That’s it! I realise that not everyone will be looking to change the value of a parameter but hopefully I have shown you a technique that you can modify to work for your own scenario. Given that this blog post is, y’know, on the web I have no doubt that someone is going to find a fault with my find regex expression and if that person is you….that’s OK. Let me know about it in the comments below and perhaps we can work together to come up with something better! Note that some parameters may have a different set of properties (for example some, but not all, of my parameters have a DTS:Required attribute) so your find regular expression may have to change accordingly. When researching this I found the following article to be invaluable: Visual Studio Find/Replace Regular Expression Usage @Jamiet

    Read the article

  • Compute Scalars, Expressions and Execution Plan Performance

    - by Paul White
    The humble Compute Scalar is one of the least well-understood of the execution plan operators, and usually the last place people look for query performance problems. It often appears in execution plans with a very low (or even zero) cost, which goes some way to explaining why people ignore it. Some readers will already know that a Compute Scalar can contain a call to a user-defined function, and that any T-SQL function with a BEGIN…END block in its definition can have truly disastrous consequences...(read more)

    Read the article

  • Regular Expressions. Remember it, write it, test it.

    - by outcoldman
    I should say that I’m fan of regular expressions. Whenever I see the problem, which I can solve with Regex, I felt a burning desire to do it and going to write new test for new regex. Previously I had installed SharpDevelop Studio just for good regular expression tool in it (Why VS doesn’t have one?). But now I’m a little wiser, and for each Regex I write a separate test. I find it difficult to remember the syntax of regular expressions (I don’t write them very often); I always forget which character is responsible for the beginning of the line, etc. So I use external small and easy articles like this “Regular expressions - An introduction”. Now I want to show you little samples of regular expressions and want to show you how to test these samples. Read more... (redirect to http://outcoldman.ru)

    Read the article

  • Evaluating mathematical expressions in Python

    - by vander
    Hi, I want to tokenize a given mathematical expression into a binary tree like this: ((3 + 4 - 1) * 5 + 6 * -7) / 2 '/' / \ + 2 / \ * * / \ / \ - 5 6 -7 / \ + 1 / \ 3 4 Is there any pure Python way to do this? Like passing as a string to Python and then get back as a tree like mentioned above. Thanks.

    Read the article

  • What’s New in The Second Edition of Regular Expressions Cookbook

    - by Jan Goyvaerts
    %COOKBOOKFRAME% The second edition of Regular Expressions Cookbook is a completely revised edition, not just a minor update. All of the content from the first edition has been updated for the latest versions of the regular expression flavors and programming languages we discuss. We’ve corrected all errors that we could find and rewritten many sections that were either unclear or lacking in detail. And lack of detail was not something the first edition was accused of. Expect the second edition to really dot all i’s and cross all t’s. A few sections were removed. In particular, we removed much talk about browser inconsistencies as modern browsers are much more compatible with the official JavaScript standard. There is plenty of new content. The second edition has 101 more pages, bringing the total to 612. It’s almost 20% bigger than the first edition. We’ve added XRegExp as an additional regex flavor to all recipes throughout the book where XRegExp provides a better solution than standard JavaScript. We did keep the standard JavaScript solutions, so you can decide which is better for your needs. The new edition adds 21 recipes, bringing the total to 146. 14 of the new recipes are in the new Source Code and Log Files chapter. These recipes demonstrate techniques that are very useful for manipulating source code in a text editor and for dealing with log files using a grep tool. Chapter 3 which has recipes for programming with regular expressions gets only one new recipe, but it’s a doozy. If anyone has ever flamed you for using a regular expression instead of a parser, you’ll now be able to tell them how you can create your own parser by mixing regular expressions with procedural code. Combined with the recipes from the new Source Code and Log Files chapter, you can create parsers for whatever custom language or file format you like. If you have any interest in regular expressions at all, whether you’re a beginner or already consider yourself an expert, you definitely need a copy of the second edition of Regular Expressions Cookbook if you didn’t already buy the first. If you did buy the first edition, and you often find yourself referring back to it, then the second edition is a very worthwhile upgrade. You can buy the second edition of Regular Expressions Cookbook from Amazon or wherever technical books are sold. Ask for ISBN 1449319432.

    Read the article

  • regular expressions: love or hate or alternatives?

    - by yamspog
    While I can see the value and usefulness of regular expressions, I also find that they are extremely complicated and difficult to create and debug. I am often at the point where I find their usefulness is offset by the difficulty in creating expressions. I am a bit astonished by the fact that there is nothing quite like them and that there hasn't been an effort to recreate them use a more verbose or less arcane syntax. so, are regular expressions here to stay? are there alternatives that are gaining traction? do other people just ignore them and write hundreds of lines of string compare functions?

    Read the article

  • Lambda Expressions

    - by Asad Khan
    Can somebody explain me lambda expressions & what they can be used for. I have googled for it & have a rough idea. most of the examples give c# code. How about lambda expressions in plain old C...?

    Read the article

  • solve mathematical equation with 1 unknown (equations are dynamically built)

    - by chris-gr
    Hi, I have to built dynamically equations like following: x + x/3 + (x/3)/4 + (x/3/4)/2 = 50 Now I would like to evaluate this equation and get x. The equation is built dynamically. x is the leaf node in a taxonomy, the other 3 nodes are the super concepts. The divisor represents the number of children of the child nodes. Is there a library that allows to build such equations dynamically and resolve x? Thanks, Chris

    Read the article

  • Mathematical problem

    - by coolboycsaba
    I have the following function: function getLevel(points) { var level = -1 + Math.sqrt(4 + points/20); // Round down to nearest level return Math.floor(level); } The above function calculates the level of a player based on their points, my problem is that I need a function like this to calculate the points needed for a given level.

    Read the article

  • Windows: File copy/move with filename regular expressions?

    - by Ian Boyd
    i basically want to run: C:\>xcopy [0-9]{13}\.(gif|jpg|png) s:\TargetFolder /s i know xcopy doesn't support regular-express filename searches. i can't find out how to find out if PowerShell has a Cmdlet to copy files; and if it does, how to find out if it supports regular expression filename matching. Can anyone think of a way to perform a recursive file copy/move with regex filename matching?

    Read the article

  • How to Process Lambda Expressions Passed as Argument Into Method - C# .NET 3.5

    - by Sunday Ironfoot
    My knowledge of Lambda expressions is a bit shaky, while I can write code that uses Lambda expressions (aka LINQ), I'm trying to write my own method that takes a few arguments that are of type Lambda Expression. Background: I'm trying to write a method that returns a Tree Collection of objects of type TreeItem from literally ANY other object type. I have the following so far: public class TreeItem { public string Id { get; set; } public string Text { get; set; } public TreeItem Parent { get; protected set; } public IList<TreeItem> Children { get { // Implementation that returns custom TreeItemCollection type } } public static IList<TreeItem> GetTreeFromObject<T>(IList<T> items, Expression<Func<T, string>> id, Expression<Func<T, string>> text, Expression<Func<T, IList<T>>> childProperty) where T : class { foreach (T item in items) { // Errrm!?? What do I do now? } return null; } } ...which can be called via... IList<TreeItem> treeItems = TreeItem.GetTreeFromObject<Category>( categories, c => c.Id, c => c.Name, c => c.ChildCategories); I could replace the Expressions with string values, and just use reflection, but I'm trying to avoid this as I want to make it strongly typed. My reasons for doing this is that I have a control that accepts a List of type TreeItem, whereas I have dozens of different types that are all in a tree like structure, and don't want to write seperate conversion methods for each type (trying to adhere to the DRY principle). Am I going about this the right way? Is there a better way of doing this perhaps?

    Read the article

  • Inspiring problems to show off the importance of regular expressions?

    - by ragu.pattabi
    I am planning to give a presentation/demonstration on regular expressions at work to encourage young developers to add this powerful and important tool in their toolbox. Just teaching syntax doesn't cut it. I often see people say nice. After the presentation, they get on with their programming lives without ever thinking of using it mostly. I am raking my grey matter to come up with some solid examples, not just problems that matches 'cat' and 'cut'. I missed to note down the occasions of my regex enlightenments to use here. :^( Do you have some inspiring problems to share that could be solved with regex?

    Read the article

  • Can non-IT people learn and take advantage of regular expressions? [closed]

    - by user1598390
    Often times, not-IT people has to deal with massive text data, clean it, filter it, modify it. Often times normal office tools like Excel lack the tools to make complex search and replace operations on text. Could this people benefit from regexps ? Can regexp be taught to them ? Are regular expressions the exclusive domain of programmers and unix/linux technicians ? Can they be learned by non-IT people, given regexps are not a programming language? Is this a valid or achievable goal to make some users regexp-literate through appopriate training ? Have you have any experiences on this issue? and if so, have it been successful ?

    Read the article

  • Regular Expressions Cookbook Code Samples

    - by Jan Goyvaerts
    %COOKBOOKFRAME% One of the common criticisms against the first edition was that we didn’t have the regular expressions and code samples available for download. Since our book only has very short code snippets rather than complete programs, we (the authors) did not have these available as separate files either. But for the second edition we’re trying to do better. You can now download the code samples from the 2nd edition of Regular Expressions Cookbook. This HTML file contains all the blocks with regular expressions and source code from the book, along with the titles of the chapters, recipes, and sections that they are found in. If you have purchased the book, you can use this file to easily copy and paste the regular expressions and source code snippets. Even if you purchased the ebook, you may prefer to use this file. The regexes in the ebook are formatted with line breaks and gray dots for spaces to make them easier to read in print. The HTML file does not use such formatting, so you can copy and paste them directly. This means that some very regexes will run beyond the edge of your browser window.

    Read the article

  • Extreme Optimization –Mathematical Constants and Basic Functions

    - by JoshReuben
    Machine constants The MachineConstants class - contains constants for floating-point arithmetic because the CLS System.Single and Double floating-point types do not follow the standard conventions and are useless. machine constants for the Double type: machine precision: Epsilon , SqrtEpsilon CubeRootEpsilon largest possible value: MaxDouble , SqrtMaxDouble, LogMaxDouble smallest Double-precision floating point number that is greater than zero: MinDouble , SqrtMinDouble , LogMinDouble A similar set of constants is available for the Single Datatype  Mathematical Constants The Constants class contains static fields for many mathematical constants and common expressions involving small integers – if you are doing thousands of iterations, you wouldn't want to calculate OneOverSqrtTwoPi , Sqrt17 or Log17 !!! Fundamental constants E - The base for the natural logarithm, e (2.718...). EulersConstant - (0.577...). GoldenRatio - (1.618...). Pi - the ratio between the circumference and the diameter of a circle (3.1415...). Expressions involving fundamental constants: TwoPi, PiOverTwo, PiOverFour, LogTwoPi, PiSquared, SqrPi, SqrtTwoPi, OneOverSqrtPi, OneOverSqrtTwoPi Square roots of small integers: Sqrt2, Sqrt3, Sqrt5, Sqrt7, Sqrt17 Logarithms of small integers: Log2, Log3, Log10, Log17, InvLog10  Elementary Functions The IterativeAlgorithm<T> class in the Extreme.Mathematics namespace defines many elementary functions that are missing from System.Math. Hyperbolic Trig Functions: Cosh, Coth, Csch, Sinh, Sech, Tanh Inverse Hyperbolic Trig Functions: Acosh, Acoth, Acsch, Asinh, Asech, Atanh Exponential, Logarithmic and Miscellaneous Functions: ExpMinus1 - The exponential function minus one, ex-1. Hypot - The hypotenuse of a right-angled triangle with specified sides. LambertW - Lambert's W function, the (real) solution W of x=WeW. Log1PlusX - The natural logarithm of 1+x. Pow - A number raised to an integer power.

    Read the article

  • Infragistics and CenterSpace Software Team Up to Deliver Mathematical Charting Solution

    Princeton, N.J. & Elstree, England & Corvallis, OR – May 5, 2010 — Infragistics, a world leader in user interface (UI) development tools and experts in the User Experience (UX) market, and CenterSpace Software, a leading provider of enterprise class numerical component libraries for the .NET platform, today announced that they have teamed up to bring a complete mathematical charting solution to .NET developers.

    Read the article

  • Javascript to match a specific number using regular expressions

    - by ren33
    I was using javascript to detect for specific key strokes and while writing the method I thought I'd try regular expressions and the test() method and came up with: if (/8|9|37|38|46|47|48|49|50|51|52|53|54|55|56|57|96|97|98|99|100|101|102|103|104|105|110/.test(num)) { // do something if there's a match } This doesn't seem to work 100% as some values seem to make it past the regex test, such as 83. I've since moved on, but I'm still curious as to why this didn't work.

    Read the article

  • PHP and Regular Expressions question?

    - by php
    I was wondering if the codes below are the correct way to check for a street address, email address, password, city and url using preg_match using regular expressions? And if not how should I fix the preg_match code? preg_match ('/^[A-Z0-9 \'.-]{1,255}$/i', $trimmed['address']) //street address preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email'] //email address preg_match ('/^\w{4,20}$/', $trimmed['password']) //password preg_match ('/^[A-Z \'.-]{1,255}$/i', $trimmed['city']) //city preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i", $trimmed['url']) //url

    Read the article

  • BASH Arithmetic Expressions

    - by Arko
    I had used several ways to do some simple integer arithmetic in BASH (3.2). But I can't figure out the best (preferred) way to do it. result=`expr 1 + 2` result=$(( 1 + 2 )) let "result = 1 + 2" What are the fundamental differences between those expressions? Is there other ways to do the same? Is the use of a tool like bc mandatory for floating point arithmetic? result=`echo "7/354" | bc`

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >