Search Results

Search found 1746 results on 70 pages for 'expressions'.

Page 11/70 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Intersection of two regular expressions

    - by Henry
    Hi, Im looking for function (PHP will be the best), which returns true whether exists string matches both regexpA and regexpB. Example 1: $regexpA = '[0-9]+'; $regexpB = '[0-9]{2,3}'; hasRegularsIntersection($regexpA,$regexpB) returns TRUE because '12' matches both regexps Example 2: $regexpA = '[0-9]+'; $regexpB = '[a-z]+'; hasRegularsIntersection($regexpA,$regexpB) returns FALSE because numbers never matches literals. Thanks for any suggestions how to solve this. Henry

    Read the article

  • boost::lambda bind expressions can't get bind to string's empty() to work

    - by navigator
    Hi, I am trying to get the below code snippet to compile. But it fails with: error C2665: 'boost::lambda::function_adaptor::apply' : none of the 8 overloads could convert all the argument types. Sepcifying the return type when calling bind does not help. Any idea what I am doing wrong? Thanks. #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> #include <string> #include <map> int main() { namespace bl = boost::lambda; typedef std::map<int, std::string> types; types keys_and_values; keys_and_values[ 0 ] = "zero"; keys_and_values[ 1 ] = "one"; keys_and_values[ 2 ] = "Two"; std::for_each( keys_and_values.begin(), keys_and_values.end(), std::cout << bl::constant("Value empty?: ") << std::boolalpha << bl::bind(&std::string::empty, bl::bind(&types::value_type::second, _1)) << "\n"); return 0; }

    Read the article

  • Problem with nested lambda expressions.

    - by Lehto
    Hey I'm trying to do a nested lambda expression like to following: textLocalizationTable.Where( z => z.SpokenLanguage.Any( x => x.FromCulture == "en-GB") ).ToList(); but i get the error: Member access 'System.String FromCulture' of 'DomainModel.Entities.SpokenLanguage' not legal on type 'System.Data.Linq.EntitySet`1[DomainModel.Entities.SpokenLanguage]. TextLocalization has this relation to spokenlanguage: [Association(OtherKey = "LocalizationID", ThisKey = "LocalizationID", Storage = "_SpokenLanguage")] private EntitySet<SpokenLanguage> _SpokenLanguage = new EntitySet<SpokenLanguage>(); public EntitySet<SpokenLanguage> SpokenLanguage { set { _SpokenLanguage = value; } get { return _SpokenLanguage; } } Any idea what is wrong?

    Read the article

  • Regular expressions and matching question marks in URLs

    - by James P.
    I'm having trouble finding a regular expression that matches the following String. Korben;http://feeds.feedburner.com/KorbensBlog-UpgradeYourMind?format=xml;1 One problem is escaping the question mark. Java's pattern matcher doesn't seem to accept \? as a valid escape sequence but it also fails to work with the tester at myregexp.com. Here's what I have so far: ([a-zA-Z0-9])+;http://([a-zA-Z0-9./-]+);[0-9]+ Any suggestions?

    Read the article

  • Locating multiple nested If statements using regular expressions

    - by TERACytE
    Is there a way to search for multiple nested if statements in code using a regular expression? For example, an expression that would locate an instance of if statements three or more layers deep with different styles (if, if/else, if/elseif/else): if (...) { <code> if (...) { <code> if (...) <code> } else if (...) { <code> } else { <code> } } else { <code> }

    Read the article

  • Regular expressions help

    - by Michael
    If I had the following HTML: <li><a href="aaa"> Thisislink1</a></li> <li><a href="abcdef"> Thisisanotherlink</a></li> <li><a href="12345"> Onemorelink</a></li> Where each link will be different in length and value. How can I search for the values inside the link (IE: Thisislink1, Thisisanotherlink and Onemorelink) with a search phrase, say 'another'. So in this example, only 'Thisisanotherlink' would be returned, but if I changed the search phrase to 'link', then all 3 values will be returned.

    Read the article

  • Function signature-like expressions as C++ template arguments

    - by Jeff Lee
    I was looking at Don Clugston's FastDelegate mini-library and noticed a weird syntactical trick with the following structure: TemplateClass< void( int, int ) > Object; It almost appears as if a function signature is being used as an argument to a template instance declaration. This technique (whose presence in FastDelegate is apparently due to one Jody Hagins) was used to simplify the declaration of template instances with a semi-arbitrary number of template parameters. To wit, it allowed this something like the following: // A template with one parameter template<typename _T1> struct Object1 { _T1 m_member1; }; // A template with two parameters template<typename _T1, typename _T2> struct Object2 { _T1 m_member1; _T2 m_member2; }; // A forward declaration template<typename _Signature> struct Object; // Some derived types using "function signature"-style template parameters template<typename _Dummy, typename _T1> struct Object<_Dummy(_T1)> : public Object1<_T1> {}; template<typename _Dummy, typename _T1, typename _T2> struct Object<_Dummy(_T1, _T2)> : public Object2<_T1, _T2> {}; // A. "Vanilla" object declarations Object1<int> IntObjectA; Object2<int, char> IntCharObjectA; // B. Nifty, but equivalent, object declarations typedef void UnusedType; Object< UnusedType(int) > IntObjectB; Object< UnusedType(int, char) > IntCharObjectB; // C. Even niftier, and still equivalent, object declarations #define DeclareObject( ... ) Object< UnusedType( __VA_ARGS__ ) > DeclareObject( int ) IntObjectC; DeclareObject( int, char ) IntCharObjectC; Despite the real whiff of hackiness, I find this kind of spoofy emulation of variadic template arguments to be pretty mind-blowing. The real meat of this trick seems to be the fact that I can pass textual constructs like "Type1(Type2, Type3)" as arguments to templates. So here are my questions: How exactly does the compiler interpret this construct? Is it a function signature? Or, is it just a text pattern with parentheses in it? If the former, then does this imply that any arbitrary function signature is a valid type as far as the template processor is concerned? A follow-up question would be that since the above code sample is valid code, why doesn't the C++ standard just allow you to do something like the following, which is does not compile? template<typename _T1> struct Object { _T1 m_member1; }; // Note the class identifier is also "Object" template<typename _T1, typename _T2> struct Object { _T1 m_member1; _T2 m_member2; }; Object<int> IntObject; Object<int, char> IntCharObject;

    Read the article

  • php array code with regular expressions

    - by user551068
    there are few mistakes which it is showing as Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in array 4,9,10,11,12... can anyone resolve them <?PHP $hosts = array( array("ronmexico.kainalopallo.com/","beforename=$F_firstname%20$F_lastname&gender=$F_gender","Your Ron Mexico Name is ","/the ultimate disguise, is <u><b>([^<]+)<\/b><\/u>/s"), array("www.fjordstone.com/cgi-bin/png.pl","gender=$F_gender&submit=Name%20Me","Your Pagan name is ","/COLOR=#000000 SIZE=6> *([^<]*)<\/FONT>/"), array("rumandmonkey.com/widgets/toys/mormon/index.php","gender=$F_gender&firstname=$F_firstname&surname=$F_lastname","Your Mormon Name is ","/<p>My Mormon name is <b>([^<]+)<\/b>!<br \/>/s"), array("cyborg.namedecoder.com/index.php","acronym=$F_firstname&design=edox&design_click-edox.x=0&design_click-edox.y=0&design_click-edox=edo","","Your Cyborg Name is ","/<p>([^<]+)<\/p>/"), array("rumandmonkey.com/widgets/toys/namegen/10/","nametype=$brit&page=2&id=10&submit=God%20save%20the%20Queen!&name=$F_firstname%20$F_lastname","Your Very British Name is ","/My very British name is \&lt\;b\&gt;([^&]+)\&lt;\/b\&gt;\.\&lt;br/"), array("blazonry.com/name_generator/usname.php","realname=$F_firstname+$F_lastname&gender=$F_gender","Your U.S. Name is ","/also be known as <font size=\'\+1\'><b>([^<]+)<\/b>/s"), array("www.spacepirate.org/rogues.php","realname=$F_firstname%20$F_lastname&formentered=Yes&submit=Arrrgh","Your Space Pirate name is ","/Your pirate name is <font size=\'\+1\'><b>([^<]+)<\/b><\/font>/s"), array("rumandmonkey.com/widgets/toys/ghetto/","firstname=$F_firstname&lastname=$F_lastname","Your Ghetto Name is ","/<p align=\"center\" style=\"font-size: 36px\">\s*<br \/>\s*([^<]*)<br \/>/"), array("www.emmadavies.net/vampire/default.aspx","mf=$emgender&firstname=$F_firstname&lastname=$F_lastname&submit=Find+My+Vampire+Name","","Your Vampire Name is ","/<i class=\"vampirecontrol vampire name\">([^<]*)<\/i>/"), array("www.emmadavies.net/fairy/default.aspx","mf=$emgender&firstname=$F_firstname&lastname=$F_lastname&submit=Seek+Fairy","","Your Fairy Name is ","/<i class=\'ng fairy name\'>([^<]*)<\/i>/"), array("www.irielion.com/israel/reggaename.html","phase=3&oldname=$F_firstname%20$F_lastname&gndr=$reggender","","Your Rasta Name is ","/Yes I, your irie new name is ([^\n]*)\n/"), array("www.ninjaburger.com/fun/games/ninjaname/ninjaname.php","realname=$F_firstname+$F_lastname","Your Ninja Burger Name is ","/<BR>Ninja Burger ninja name will be<BR><BR><FONT SIZE=\'\+1\'>([^<]*)<\/FONT>/"), array("gangstaname.com/pirate_name.php","sex=$F_gender&name=$F_firstname+$F_lastname","Your Pirate Name is ","/<p><strong>We\'ll now call ye:<\/strong><\/p> *<h2 class=\"newName\">([^<]*)<\/h2>/"), array("www.xach.com/nerd-name/","name=$F_firstname+$F_lastname&gender=$F_gender","Your Nerd Name is ","/<p><div align=center class=\"nerdname\">([^<]*)<\/div>/"), array("rumandmonkey.com/widgets/toys/namegen/5941/","page=2&id=5941&nametype=$dj&name=$F_firstname+$F_lastname","Your DJ Name is ","/My disk spinnin nu name is &lt\;b&gt\;([^<]*)&lt\;\/b&gt\;\./"), array("pizza.sandwich.net/poke/pokecgi.cgi","name=$F_firstname%20$F_lastname&color=black&submit=%20send%20","Your Pokename is ","/Your Pok&eacute;name is: <h1>([^<]*)<\/h1>/") ); return $hosts; ?>

    Read the article

  • Regular expressions

    - by Infinity
    Hello guys! I need a regular expression for findin a pattern. This is the pattern: id|name|code|mobile I created a pattern for this if I want to search by id (if id = 1): .*1.*|.*|.*|.* But it matches every pattern that contains number 1. What's the problem with it?

    Read the article

  • Weird bug with C++ lambda expressions in VS2010

    - by Andrei Tita
    In a couple of my projects, the following code: class SmallClass { public: int x1, y1; void TestFunc() { auto BadLambda = [&]() { int g = x1 + 1; //ok int h = y1 + 1; //c2296 int l = static_cast<int>(y1); //c2440 }; int y1_copy = y1; //it works if you create a local copy auto GoodLambda = [&]() { int h = y1_copy + 1; //ok int l = this->y1 + 1; //ok }; } }; generates error C2296: '+' : illegal, left operand has type 'double (__cdecl *)(double)' or alternatively error C2440: 'static_cast' : cannot convert from 'double (__cdecl *)(double)' to 'int' You get the picture. It also happens if catching by value. The error seems to be tied to the member name "y1". It happened in different classes, different projects and with (seemingly) any type for y1; for example, this code: [...] MyClass y1; void TestFunc() { auto BadLambda = [&]()->void { int l = static_cast<int>(y1); //c2440 }; } generates both these errors: error C2440: 'static_cast' : cannot convert from 'MyClass' to 'int' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called error C2440: 'static_cast' : cannot convert from 'double (__cdecl *)(double)' to 'int' There is no context in which this conversion is possible It didn't, however, happen in a completely new project. I thought maybe it was related to Lua (the projects where I managed to reproduce this bug both used Lua), but I did not manage to reproduce it in a new project linking Lua. It doesn't seem to be a known bug, and I'm at a loss. Any ideas as to why this happens? (I don't need a workaround; there are a few in the code already). Using Visual Studio 2010 Express version 10.0.40219.1 Sp1Rel.

    Read the article

  • Using \b in C# regular expressions doesn't work?

    - by Nikhil
    I am wondering why the following regex does not match. string query = "\"1 2\" 3"; string pattern = string.Format(@"\b{0}\b", Regex.Escape("\"1 2\"")); string repl = Regex.Replace(query, pattern, "", RegexOptions.CultureInvariant); Note that if I remove the word boundary characters (\b) from pattern, it matches fine. Is there something about '\b' that might be tripping this up?

    Read the article

  • Serializing WPF DataTemplates and {Binding Expressions} (from PowerShell?)

    - by Jaykul
    Ok, here's the deal: I have code that works in C#, but when I call it from PowerShell, it fails. I can't quite figure it out, but it's something specific to PowerShell. Here's the relevant code calling the library (assuming you've added a reference ahead of time) from C#: public class Test { [STAThread] public static void Main() { Console.WriteLine( PoshWpf.XamlHelper.RoundTripXaml( "<TextBlock Text=\"{Binding FullName}\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"/>" ) ); } } Compiled into an executable, that works fine ... but if you call that method from PowerShell, it returns with no {Binding FullName} for the Text! add-type -path .\PoshWpf.dll [PoshWpf.Test]::Main() I've pasted below the entire code for the library, all wrapped up in a PowerShell Add-Type call so you can just compile it by pasting it into PowerShell (you can leave off the first and last lines if you want to paste it into a new console app in Visual Studio. To output (from PowerShell 2) as an executable, just change the -OutputType parameter to ConsoleApplication and the -OutputAssembly to PoshWpf.exe (or something). Thus, you can see that running the SAME CODE from the executable gives you the correct output. But running the two lines as above or manually calling [PoshWpf.XamlHelper]::RoundTripXaml or [PoshWpf.XamlHelper]::ConvertToXaml from PowerShell just doesn't seem to work at all ... HELP?! Add-Type -TypeDefinition @" using System; using System.ComponentModel; using System.Globalization; using System.Linq; using System.Windows; using System.Windows.Data; using System.Windows.Markup; namespace PoshWpf { public class Test { [STAThread] public static void Main() { Console.WriteLine( PoshWpf.XamlHelper.RoundTripXaml( "<TextBlock Text=\"{Binding FullName}\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"/>" ) ); } } public class BindingTypeDescriptionProvider : TypeDescriptionProvider { private static readonly TypeDescriptionProvider _DEFAULT_TYPE_PROVIDER = TypeDescriptor.GetProvider(typeof(Binding)); public BindingTypeDescriptionProvider() : base(_DEFAULT_TYPE_PROVIDER) { } public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) { ICustomTypeDescriptor defaultDescriptor = base.GetTypeDescriptor(objectType, instance); return instance == null ? defaultDescriptor : new BindingCustomTypeDescriptor(defaultDescriptor); } } public class BindingCustomTypeDescriptor : CustomTypeDescriptor { public BindingCustomTypeDescriptor(ICustomTypeDescriptor parent) : base(parent) { } public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptor pd; var pdc = new PropertyDescriptorCollection(base.GetProperties(attributes).Cast<PropertyDescriptor>().ToArray()); if ((pd = pdc.Find("Source", false)) != null) { pdc.Add(TypeDescriptor.CreateProperty(typeof(Binding), pd, new Attribute[] { new DefaultValueAttribute("null") })); pdc.Remove(pd); } return pdc; } } public class BindingConverter : ExpressionConverter { public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return (destinationType == typeof(MarkupExtension)) ? true : false; } public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(MarkupExtension)) { var bindingExpression = value as BindingExpression; if (bindingExpression == null) throw new Exception(); return bindingExpression.ParentBinding; } return base.ConvertTo(context, culture, value, destinationType); } } public static class XamlHelper { static XamlHelper() { // this is absolutely vital: TypeDescriptor.AddProvider(new BindingTypeDescriptionProvider(), typeof(Binding)); TypeDescriptor.AddAttributes(typeof(BindingExpression), new Attribute[] { new TypeConverterAttribute(typeof(BindingConverter)) }); } public static string RoundTripXaml(string xaml) { return XamlWriter.Save(XamlReader.Parse(xaml)); } public static string ConvertToXaml(object wpf) { return XamlWriter.Save(wpf); } } } "@ -language CSharpVersion3 -reference PresentationCore, PresentationFramework, WindowsBase -OutputType Library -OutputAssembly PoshWpf.dll Again, you can get an executable by just altering the last line like so: "@ -language CSharpVersion3 -reference PresentationCore, PresentationFramework, WindowsBase -OutputType ConsoleApplication -OutputAssembly PoshWpf.exe

    Read the article

  • What is "branch-on-sign expressions"?

    - by Pavel Shved
    As far as I understand the "branch-on-sign" is the name of some kind of if statement that does something depending on sign. I'm not sure that it's just if (x<0) then ... else .... However, the name "branch-on-sign" seems to denote something very concrete. So, what is it? Perhaps, it's language-specific, but I don't really know. Probably, it's related to embedded development.

    Read the article

  • Cache Wrapper with expressions

    - by Fujiy
    I dont know if is possible. I want a class to encapsulate all Cache of my site. I thinking about the best way to do this to avoid conflict with keys. My first idea is something like this: public static TResult Cachear<TResult>(this Cache cache, Expression<Func<TResult>> funcao) { string chave = funcao.ToString(); if (!(cache[chave] is TResult)) { cache[chave] = funcao.Compile()(); } return (TResult)cache[chave]; } Is the best way? Ty

    Read the article

  • How Oracle 10g evaluates NULL in boolean expressions

    - by Phani Kumar PV
    if not (i_ReLaunch = 1 and (dt_enddate is not null)) How this epression will be evaluated in Oracle 10g when the input value of the i_ReLaunch = null and the value of the dt_enddate is not null it is entering the loop. According to the rules in normal c# and all it should not enter the loop as it will be as follows with the values. If( not(false and (true)) = if not( false) =if( true) which implies it should enters the loop But it is not happening Can someone let me know if i am wrong at any place

    Read the article

  • Linq DateTime expressions wont compare if only one is nullable

    - by tigermain
    I have been getting the following exception: The binary operator GreaterThanOrEqual is not defined for the types 'System.Nullable`1[System.DateTime]' and 'System.DateTime'. I am getting the left hand expression from a class property which is a nullable datetime variable and my right hand side is using Expression.Constant(new Nullable<DateTime>(DateTime.Now)) However I still get the above exception despite explicitly setting the right hand expression to a nullable type

    Read the article

  • Regular expressions - finding and comparing the first instance of a word

    - by Dan
    Hi there, I am currently trying to write a regular expression to pull links out of a page I have. The problem is the links need to be pulled out only if the links have 'stock' for example. This is an outline of what I have code wise: <td class="prd-details"> <a href="somepage"> ... <span class="collect unavailable"> </td> <td class="prd-details"> <a href="somepage"> ... <span class="collect available"> </td> What I would like to do is pull out the links only if 'collect available' is in the tag. I have tried to do this with the regular expression: (?s)prd-details[^=]+="([^"]+)" .+?collect{1}[^\s]+ available However on running it, it will find the first 'prd-details' class and keep going until it finds 'collect available', thereby taking the incorrect results. I thought by specifying the {1} after the word collect it would only use the first instance of the word it finds, but apparently I'm wrong. I've been trying to use different things such as positive and negative lookaheads but I cant seem to get anything to work. Might anyone be able to help me with this issue? Thanks, Dan

    Read the article

  • Regular Expressions in PHP

    - by kelly
    Sorry for unclear description, my English is not good. My problem is that I want to decode a string, and this string has nested content delimited by {}. For example: The string: {any string0{any string 00{any string 000....}}}{any string1}any string. The result I want to get: array[0] = {any string0{any string 00{any string 000....}}} array[1] = {any string1} I hope it's clear enough.

    Read the article

  • Strange behavior: Dynamic expressions with RegExp Object in RegExp.match (Javascript)

    - by NeDark
    I have detect a strange behavior in regexps created with the RegExp object: With this code: var exp1 = /./; var exp2 = new RegExp('.'); ? var test1 = exp1.test('large\n\ntext..etc.'); var test2 = exp2.test('large\n\ntext..etc.'); ? var match1 = 'large\n\ntext..etc.'.match(exp1); var match2 = 'large\n\ntext..etc.'.match(exp2); ...the result is: test1 = true test2 = true ? match1 = 'l' (first match) match2 = null With the regexp maked with the regexp object from a string it finds nothing... Why does this happends? Thanks!!

    Read the article

  • How to allow user to set expressions detrmining property value in PropertyGrid

    - by savras
    I noticed that programs like Report Builder allow user to set property value or an expression determining property value. I want to the add same functionality to my application. So is there any simple way to do so or do i have to redefine all type converters so that they allow to set expression in addition to their original functionality. http://img204.imageshack.us/img204/7934/48707358.jpg

    Read the article

  • Initializing PHP class property declarations with simple expressions yields syntax error

    - by user171929
    According to the PHP docs, one can initialize properties in classes with the following restriction: "This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated." I'm trying to initialize an array and having some issues. While this works fine: public $var = array( 1 => 4, 2 => 5, ); This creates a syntax error: public $var = array( 1 => 4, 2 => (4+1), ); Even this isn't accepted: public $var = 4+1; which suggests it's not a limitation of the array() language construct. Now, the last time I checked, "4+1" equated to a constant value that not only should be accepted, but should in fact be optimized away. In any case, it's certainly able to be evaluated at compile-time. So what's going on here? Is the limitation really along the lines of "cannot be any calculated expression at all", versus any expression "able to be evaluated at compile time"? The use of "evaluated" in the doc's language suggests that simple calculations are permitted, but alas.... If this is a bug in PHP, does anyone have a bug ID? I tried to find one but didn't have any luck.

    Read the article

  • Best practice with respect to NPE and multiple expressions on single line

    - by JRL
    I'm wondering if it is an accepted practice or not to avoid multiple calls on the same line with respect to possible NPEs, and if so in what circumstances. For example: getThis().doThat(); vs Object o = getThis(); o.doThat(); The latter is more verbose, but if there is an NPE, you immediately know what is null. However, it also requires creating a name for the variable and more import statements. So my questions around this are: Is this problem something worth designing around? Is it better to go for the first or second possibility? Is the creation of a variable name something that would have an effect performance-wise? Is there a proposal to change the exception message to be able to determine what object is null in future versions of Java ?

    Read the article

  • Regular expressions and matching URLs with metacharacters

    - by James P.
    I'm having trouble finding a regular expression that matches the following String. Korben;http://feeds.feedburner.com/KorbensBlog-UpgradeYourMind?format=xml;1 One problem is escaping the question mark. Java's pattern matcher doesn't seem to accept \? as a valid escape sequence but it also fails to work with the tester at myregexp.com. Here's what I have so far: ([a-zA-Z0-9])+;http://([a-zA-Z0-9./-]+);[0-9]+ Any suggestions? Edit: The original intent was to match all URLs that could be found after the first semi colon.

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >