Search Results

Search found 6394 results on 256 pages for 'regular expressions'.

Page 17/256 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • typesafe NotifyPropertyChanged using linq expressions

    - by bitbonk
    Form Build your own MVVM I have the following code that lets us have typesafe NotifyOfPropertyChange calls: public void NotifyOfPropertyChange<TProperty>(Expression<Func<TProperty>> property) { var lambda = (LambdaExpression)property; MemberExpression memberExpression; if (lambda.Body is UnaryExpression) { var unaryExpression = (UnaryExpression)lambda.Body; memberExpression = (MemberExpression)unaryExpression.Operand; } else memberExpression = (MemberExpression)lambda.Body; NotifyOfPropertyChange(memberExpression.Member.Name); } How does this approach compare to standard simple strings approach performancewise? Sometimes I have properties that change at a very high frequency. Am I safe to use this typesafe aproach? After some first tests it does seem to make a small difference. How much CPU an memory load does this approach potentially induce?

    Read the article

  • .NET equivalent to Perl regular expressions

    - by r_honey
    I need to convert a Perl script to VB.NET. I have managed almost the entire conversion, but some Perl (seemingly simple) regex are causing an headache. Can someone suggest me .NET equivalent of the following perl regex: 1) $letter =~ s/Users //,; $letter =~ s/Mailboxes //,; if($letter =~ m/$first_char/i){ 2) unless($storegroup =~ /Recovery/ || $storegroup =~ /Users U V W X Y Z/ || $storegroup =~ /Users S T/ || $storegroup =~ /Users Q R/){ The regex look simple to me. I tried to wade through perl.org but understanding a langugae regex takes sometime and I need to complete the conversion quickly.

    Read the article

  • matching files with regular expressions

    - by Javier
    Dear all, I have an input file with a list of movies (Note that there might be some repeated entries): American_beauty__1h56mn38s_ As_Good_As_It_Gets As_Good_As_It_Gets _DivX-ITA__Casablanca_M_CURTIZ_1942_Bogart-bergman_ Capote_EN_DVDRiP_XViD-GeT-AW _DivX-ITA__Casablanca_M_CURTIZ_1942_Bogart-bergman_ I would to find the corresponding match (line number) from another reference file for each of the entries in the first file: American beauty.(1h56mn38s) As Good As It Gets Capote.EN.DVDRiP.XViD-GeT-AW [DivX-ITA] Casablanca(M.CURTIZ 1942 Bogart-bergman) Quills (2000)(7.4) The desired output would be something like (Reference Movie + Line number from the Reference File): American beauty.(1h56mn38s) 1 As Good As It Gets 2 As Good As It Gets 2 [DivX-ITA] Casablanca(M.CURTIZ 1942 Bogart-bergman) 4 Capote.EN.DVDRiP.XViD-GeT-AW 3 [DivX-ITA] Casablanca(M.CURTIZ 1942 Bogart-bergman) 4 Basically, the difference between the entries in both files is that some characters such as: blank spaces, parenthesis, points, etc. have been replaced by underscores. Does anybody could shed some light on it? Best wishes, Javier

    Read the article

  • Understanding evaluation of expressions containing '++' and '->' operators in C.

    - by Leif Ericson
    Consider this example: struct { int num; } s, *ps; s.num = 0; ps = &s; ++ps->num; printf("%d", s.num); /* Prints 1 */ It prints 1. So I understand that it is because according to operators precedence, -> is higher than ++, so the value ps->num (which is 0) is firstly fetched and then the ++ operator operates on it, so it increments it to 1. struct { int num; } s, *ps; s.num = 0; ps = &s; ps++->num; printf("%d", s.num); /* Prints 0 */ In this example I get 0 and I don't understand why; the explanation of the first example should be the same for this example. But it seems that this expression is evaluated as follows: At first, the operator ++ operates, and it operates on ps, so it increments it to the next struct. Only then -> operates and it does nothing because it just fetches the num field of the next struct and does nothing with it. But it contradicts the precedence of operators, which says that -> have higher precedence than ++. Can someone explain this behavior? Edit: After reading two answers which refer to a C++ precedence tables which indicate that a prefix ++/-- operators have lower precedence than ->, I did some googling and came up with this link that states that this rule applies also to C itself. It fits exactly and fully explains this behavior, but I must add that the table in this link contradicts a table in my own copy of K&R ANSI C. So if you have suggestions as to which source is correct I would like to know. Thanks.

    Read the article

  • Merging two Regular Expressions to Truncate Words in Strings

    - by Alix Axel
    I'm trying to come up with the following function that truncates string to whole words (if possible, otherwise it should truncate to chars): function Text_Truncate($string, $limit, $more = '...') { $string = trim(html_entity_decode($string, ENT_QUOTES, 'UTF-8')); if (strlen(utf8_decode($string)) > $limit) { $string = preg_replace('~^(.{1,' . intval($limit) . '})(?:\s.*|$)~su', '$1', $string); if (strlen(utf8_decode($string)) > $limit) { $string = preg_replace('~^(.{' . intval($limit) . '}).*~su', '$1', $string); } $string .= $more; } return trim(htmlentities($string, ENT_QUOTES, 'UTF-8', true)); } Here are some tests: // Iñtërnâtiônàlizætiøn and then the quick brown fox... (49 + 3 chars) echo dyd_Text_Truncate('Iñtërnâtiônàlizætiøn and then the quick brown fox jumped overly the lazy dog and one day the lazy dog humped the poor fox down until she died.', 50, '...'); // Iñtërnâtiônàlizætiøn_and_then_the_quick_brown_fox_... (50 + 3 chars) echo dyd_Text_Truncate('Iñtërnâtiônàlizætiøn_and_then_the_quick_brown_fox_jumped_overly_the_lazy_dog and one day the lazy dog humped the poor fox down until she died.', 50, '...'); They both work as it is, however if I drop the second preg_replace() I get the following: Iñtërnâtiônàlizætiøn_and_then_the_quick_brown_fox_jumped_overly_the_lazy_dog and one day the lazy dog humped the poor fox down until she died.... I can't use substr() because it only works on byte level and I don't have access to mb_substr() ATM, I've made several attempts to join the second regex with the first one but without success. Please help S.M.S., I've been struggling with this for almost an hour. EDIT: I'm sorry, I've been awake for 40 hours and I shamelessly missed this: $string = preg_replace('~^(.{1,' . intval($limit) . '})(?:\s.*|$)?~su', '$1', $string); Still, if someone has a more optimized regex (or one that ignores the trailing space) please share: "Iñtërnâtiônàlizætiøn and then " "Iñtërnâtiônàlizætiøn_and_then_" EDIT 2: I still can't get rid of the trailing whitespace, can someone help me out?

    Read the article

  • SQL: Recursively get parent records using Common Table Expressions

    - by Martijn B
    Hi there, Suposse you have to following tables where a sale consists of products and a product can be placed in multiple categories. Whereby categories have a hierachly structure like: Man Shoes Sport Casual Watches Women Shoes Sport Casual Watches Tables: Sale: id name 1 Sale1 Product: id saleidfk name 1 1 a 2 1 b 3 1 c 4 1 d 5 1 e ProductCategory : productid categoryid 1 3 2 3 3 4 4 5 5 10 Category: id ParentCategoryIdFk name 1 null Men 2 1 Shoes 3 2 Sport 4 2 Casual 5 1 Watches 6 null Women 7 6 Shoes 8 7 Sport 9 7 Casual 10 6 Watches Question: Now on my website I want to create a control where only the categories are shown of a certain sale and where the categories are filled with the products of the sale. I also want to include the hierachly structure of the categories. So if we have a leave node, recusivly go up to the top node. So with sale1 I should have a query with the following result: Men Shoes Sport Casual Watches Women Watches This thing is driving me crazy :-) Thanks in advance! Gr Martijn

    Read the article

  • Converting F# Quotations into LINQ Expressions

    - by forki23
    Hi, I can convert a quotation of type Expr<'a -> 'b> to a Linq expression via the following snippet: /// Converts a F# Expression to a LINQ Lambda let toLambda (exp:Expr) = let linq = exp.ToLinqExpression() :?> MethodCallExpression linq.Arguments.[0] :?> LambdaExpression /// Converts a Lambda quotation into a Linq Lamba Expression with 1 parameter let ToLinq (exp : Expr<'a -> 'b>) = let lambda = toLambda exp Expression.Lambda<Func<'a, 'b>>(lambda.Body, lambda.Parameters) Now I want to convert a quotation of type Expr<'a * 'b -> 'c> or maybe even Expr<'a -> 'b -> 'c> to a Linq Lambda Expression of type Expression<Func<'a,'b'c>>. How can I do this? Regards, forki

    Read the article

  • VBScript + Regular Expressions

    - by Karthik
    Dim sString sString = "John;Mary;Anne;Adam;Bill;Ester" Is there a regex I can use to retrieve the following from the above list: John (; at the end of the name) Anne (; at the beginning and end) Ester (; at the beginning) I am currently using the following regex for each: 1. Joh.* 2. .*An.* 3. .*st.* But, the above retrieves the entire string instead of the values I want. How can I get the correct values? Code: Dim oRegex : Set oRegex = New RegExp oRegex.Global = False oRegex.IgnoreCase = False 'John oRegex.Pattern = "Joh.*" Set oMatch = oRegex.Execute(sString) sName = oMatch(0) The above code retrieves the entire string, instead of only John. Same issue with the others :(

    Read the article

  • Destructuring assignment in generator expressions and array comprehensions

    - by Eli Grey
    Why does for ([] in object); work fine but [void 0 for ([] in object)] or (void 0 for ([] in object)) throw a syntax error for invalid left-hand assignment? For example, I would expect the following code to work, but it doesn't (the assertion isn't even done due to the syntax error): let ( i = 0, arr = [1, 2, 3, 4], gen = (i for (i in arr) if (arr.hasOwnProperty(i)) ) { for ([] in gen) i++; console.assertEquals([void 0 for ([] in gen)].length, i); }

    Read the article

  • Beginner questions on Java Regular Expression

    - by Robert
    Hello everyone. I began studying Java Regular Expression recently and I found some really intersting task.For example,I now need to dig out "Product Name","Product Description" and "Sellers for this product" out of the following HTML code.(I am sorry for the big chunck of code,but it is very straightforward) <td class="sr-check"> <input type="checkbox" name="cptitle" value="678560038" /></td> <td class="sr-image" style="width: 80px;"><a href="/Nikon-D300S-12-3-678560038/prices-html" class="strictRule" rel="nofollow"><img src="http://img01.static-nextag.com/image/Nikon-D300S-12-3-MP-Digital-SLR-Camera-Body-Black/0/000/006/789/461/678946110.jpg" alt="Nikon D300S 12.3 MP Digital SLR Camera Body - Black" class="imageLink strictRule" height="75" width="75" id="opILink_0" title="Nikon Digital Cameras - Nikon D300S 12.3 MP Digital SLR Camera Body - Black" /></a><div class="breaker">&nbsp;</div></td> <td class="sr-info"> <div class="sr-info"> <a id="opPNLink_0" class="underline" style="font-size:16px" href="/Nikon-D300S-12-3-678560038 /prices-html" >Nikon D300S 12.3 MP <b>Digital</b> SLR <b>Camera</b> Body - Black</a> <div class="sr-subinfo"> <div class="sr-info-description">SLR - 13.1MP, 12.3MP - 1x Optical Zoom - CompactFlash, SD/MMC Memory Card - 3in.</div> <div class="rating"> <img src="http://img01.static-nextag.com/imagefiles/stars/stars4_10px.gif" alt="4/5 stars" title="4/5 stars" /> (92 user ratings)</div> <div style="clear: both;"> <!-- nxtginc=nextag.api.ServerInclude$JSPIncludeWriter(/buyer/ATLSSI.jsp?ptid=678560038&dts=y) --> <a id="_atl_0" style="" href="http://www.nextag.com/serv/main/buyer/MyPDir.jsp?list=_transCookieList&amp;cmd=add&amp;ptitle=678560038" rel="nofollow">+ Add to Shopping List</a> &nbsp;|&nbsp; <!-- endnxtginc --> <a rel="nofollow" id="mltLink_0" class="mlt-link" href="/Digital-Cameras--zz500001z2z678560038zB2dgz5---html">See More Like This</a> </div> <div id="fsLink_0" class="featuredSeller"> <a rel="nofollow" class="featuredSeller" id="opFSLink_0_0" href="/norob/PtitleSeller.jsp?chnl=main&amp;tag=785646073amp;ctx=x%2BN%2Fs9zy56l4u8RXCzALE1jeLesDMzeK09rPQEdK3Yjx395ZzX9cMh9N5JAxjk7xPqF9hjk2ztM5IRXU5nspLubIXYaVzI%2B%2Fg7h1Qz58TzgvrWuNawV8qEIqqSmClArWMq6mpzNRuSlgg2xCXYObNnaIH00iKSUmBawDRvecwbCpAxhXgXoLEiEinTwr3EipComdzxL9UHFYTLoWUToUB5SRSsolQmEJ3mgnnvu83%2FC8W34TGpN9mJo%2BnyAeTkt4&amp;ptitle=678560038" target="_blank" >Thundercameras</a>:$1,289 &nbsp; <a rel="nofollow" class="featuredSeller" id="opFSLink_0_1" href="/norob/PtitleSeller.jsp?chnl=main&amp;tag=797076595&amp;ctx=x%2BN%2Fs9zy56l4u8RXCzALE1jeLesDMzeK09rPQEdK3Yjx395ZzX9cMh9N5JAxjk7xPqF9hjk2ztM5IRXU5nspLubIXYaVzI%2B%2Fg7h1Qz58TzgvrWuNawV8qEIqqSmClArWMq6mpzNRuSlgg2xCXYObNrcWLhL%2BhryuAGhXNhYSPE%2BpAxhXgXoLEiEinTwr3EipComdzxL9UHFYTLoWUToUB5SRSsolQmEJ3mgnnvu83%2FC8W34TGpN9mJo%2BnyAeTkt4&amp;ptitle=678560038" target="_blank" >PhotoVideoSuperStore</a>:$1,269 &nbsp; <a rel="nofollow" class="featuredSeller" id="opFSLink_0_2" href="/norob/PtitleSeller.jsp?chnl=main&amp;tag=803555293&amp;ctx=x%2BN%2Fs9zy56l4u8RXCzALE1jeLesDMzeK09rPQEdK3Yjx395ZzX9cMh9N5JAxjk7xPqF9hjk2ztM5IRXU5nspLubIXYaVzI%2B%2Fg7h1Qz58TzgvrWuNawV8qEIqqSmClArWMq6mpzNRuSlgg2xCXYObNt06qcvLJ5UQz7S3zKd4urWpAxhXgXoLEiEinTwr3EipComdzxL9UHFYTLoWUToUB5SRSsolQmEJ3mgnnvu83%2FC8W34TGpN9mJo%2BnyAeTkt4&amp;ptitle=678560038" target="_blank" >Digitalelect</a>:$1,279 &nbsp;</div> I would think of : (1) digging out the product name from <td class="sr-image >tag,and using regular expression exp ="<td><span\\s+class=\"sr-image\"[^>]*>" + ".*?</span><a href=\"" + "([^\"]+)" + "\"[^>]*>" + "([^<]+)" + "</a>.*?</td>"; (2) digging out the product info from the <div class="sr-info-description"> tag. exp = "<div class="sr-info-description"> [^>]*>" (3) digging out the Sellers' names from <div id="fsLink_0" class="featuredSeller"> tag. exp = "<div id="fslink_0" class="featuredSeller[^>]*>" + ".*?</span><a rel=\"" + "([^\"]+)" + "\"[^>]*>" + "([^<]+)" + "</a>.*?</td>"; I am just beginning learing using Java Regular Expression,I would be grateful if you could correct me if I am in the wrong track or my regular expressiona are wrong. Thanks a lot,guys.

    Read the article

  • When should you use intermediate variables for expressions?

    - by froadie
    There are times that one writes code such as this: callSomeMethod(someClass.someClassMethod()); And other times when one would write the same code like this: int result = someClass.someClassMethod(); callSomeMethod(result); This is just a basic example to illustrate the point. My question isn't if you should use an intermediate variable or not, as that depends on the code and can sometimes be a good design decision and sometimes a terrible one. The question is - when would you choose one method over the other? What factors would you consider when deciding whether to use an intermediate step? (I'd assume length and understandability of the fully inlined code would have something to do with it...)

    Read the article

  • 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 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

  • 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

  • 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

  • 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

  • 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

  • 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

  • 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

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >