Search Results

Search found 6715 results on 269 pages for 'preg match'.

Page 160/269 | < Previous Page | 156 157 158 159 160 161 162 163 164 165 166 167  | Next Page >

  • Funny characters in my db

    - by hdx
    My web app is breaking when I try edit a certain content type and I'm pretty sure it is because of some weird characters in my database. So when I do: SELECT body FROM message WHERE id = 666 it returns: <p>⢠<span></span></p><p><br /></p><p><em><strong>NOTE:</strong> Please remember to use your to participate in the discussion.</em></p> However when I try to count how many documents have those characters postgres complains: foo_450_prod=# SELECT COUNT(*) FROM message WHERE body LIKE'%â¢%'; ERROR: invalid byte sequence for encoding "UTF8": 0xe2a225 HINT: This error can also happen if the byte sequence does not match the encodi Does anybody know what the issue is and how I can query for those funny characters? Thanks in advance!

    Read the article

  • A very basic issue with routes in ruby

    - by Haris
    I am new to ruby and while creating a sample application found out an issue that whenever I go to http://127.0.0.1:3000/people/index by default show action is executed and index is taken as a parameter. This is server log: Started GET "/people/index" for 127.0.0.1 at 2010-12-23 18:43:01 +0500 Processing by PeopleController#show as HTML Parameters: {"id"=>"index"} I have this in my route file: root :to => "people#index" resources> :people match ':controller(/:action(/:id(.:format)))' What is going on here and how can I fix the issue?

    Read the article

  • rewrite URLs in CSS files

    - by Don
    Hi, I'm writing a Maven plugin that merges CSS files together. So all the CSS files that match /foo/bar/*.css might get merged to /foo/merged.css. A concern is that in a file such as /foo/bar/baz.css there might be a property such as: background: url("images/pic.jpg") So when the file is merged into /foo/merged.css this will need to be changed to background: url("bar/images/pic.jpg") The recalculated URL obviously depends on 3 factors: original URL original CSS file location merged CSS file location Assuming that the original and merged CSS files are both on the same filesystem, is there a general formula (or Java library) that can be used to calculate the new url given these 3 inputs? Thanks, Don

    Read the article

  • Filter user input (paragraph) for links + smileys

    - by Alec Smart
    Hello, I am looking at some sort of existing filter which can sanitize the user input to avoid XSS. Probably I can use htmlspecialchars for that. But at the same time I want to be able to parse all links (should match a.com, www.a.com and http://www.a.com and if it is http://www.aaaaaaaaaaaaaaaaaaaaaaaaaa.com then it should display it as aaa..a.com), e-mails and smileys. I am wondering what is the best way to go about it. I am currently using a php function with some regex, but many times the regex simply fails (because of link recognition is incorrect etc.). I want something very similar to the parser used during Google Chat (even a.com works). Thank you for your time.

    Read the article

  • PHP getopt Operations

    - by Rachel
    This question is regarding getopt function in php. I need to pass two parameter to the php scripts like php script.php -f filename -t filetype Now depending upon the file type which can be u, c or s I need to do proper operation. I am using switch case for the same: Here is the Code I am using: // Get filename of input file when executing through command line. $file = getopt("f:t:"); Switch case should compare the type of the file which I am passing in from the command line (u, c or i) and accordingly match it and do the operation. switch("I am not sure what should go in there and this is wrong,Please advice") { case `Not sure`: $p->ini(); break; case `Not sure`: $p->iniCon(); break; case `Not sure`: $p->iniImp(); break; } Kindly advise on this !!!

    Read the article

  • Subset sum problem

    - by MadBoy
    I'm having a problem with counting which is continuation of this question. I am not really a math person so it's really hard for me to figure out this subset sum problem which was suggested as resolution. I'm having 4 ArrayList in which I hold data: alId, alTransaction, alNumber, alPrice Type | Transaction | Number | Price 8 | Buy | 95.00000000 | 305.00000000 8 | Buy | 126.00000000 | 305.00000000 8 | Buy | 93.00000000 | 306.00000000 8 | Transfer out | 221.00000000 | 305.00000000 8 | Transfer in | 221.00000000 | 305.00000000 8 | Sell | 93.00000000 | 360.00000000 8 | Sell | 95.00000000 | 360.00000000 8 | Sell | 126.00000000 | 360.00000000 8 | Buy | 276.00000000 | 380.00000000 In the end I'm trying to get what's left for customer and what's left I put into 3 array lists: alNew (corresponds to alNumber), alNewPoIle (corresponds to alPrice), and alNewCo (corrseponds to alID) ArrayList alNew = new ArrayList(); ArrayList alNewPoIle = new ArrayList(); ArrayList alNewCo = new ArrayList(); for (int i = 0; i < alTransaction.Count; i++) { string tempAkcjeCzynnosc = (string) alTransaction[i]; string tempAkcjeInId = (string) alID[i]; decimal varAkcjeCena = (decimal) alPrice[i]; decimal varAkcjeIlosc = (decimal) alNumber[i]; int index; switch (tempAkcjeCzynnosc) { case "Transfer out": case "Sell": index = alNew.IndexOf(varAkcjeIlosc); if (index != -1) { alNew.RemoveAt(index); alNewPoIle.RemoveAt(index); alNewCo.RemoveAt(index); } else { ArrayList alTemp = new ArrayList(); decimal varAkcjeSuma = 0; for (int j = 0; j < alNew.Count; j ++) { string akcjeInId = (string) alNewCo[j]; decimal akcjeCena = (decimal) alNewPoIle[j]; decimal akcjeIlosc = (decimal) alNew[j]; if (tempAkcjeInId == akcjeInId && akcjeCena == varAkcjeCena) { alTemp.Add(j); varAkcjeSuma = varAkcjeSuma + akcjeIlosc; } } if (varAkcjeSuma == varAkcjeIlosc) { for (int j = alTemp.Count -1 ; j >=0 ; j --) { int tempIndex = (int) alTemp[j]; alNew.RemoveAt(tempIndex); alNewPoIle.RemoveAt(tempIndex); alNewCo.RemoveAt(tempIndex); } } } break; case "Transfer In": case "Buy": alNew.Add(varAkcjeIlosc); alNewPoIle.Add(varAkcjeCena); alNewCo.Add(tempAkcjeInId); break; } } Basically I'm adding and removing things from Array depending on Transaction Type, Transaction ID and Numbers. I'm adding numbers to ArrayList like 156, 340 (when it is TransferIn or Buy) etc and then i remove them doing it like 156, 340 (when it's TransferOut, Sell). My solution works for that without a problem. The problem I have is that for some old data employees were entering sum's like 1500 instead of 500+400+100+500. How would I change it so that when there's Sell/TransferOut or Buy/Transfer In and there's no match inside ArrayList it should try to add multiple items from thatArrayList and find elements that combine into aggregate. Inside my code I tried to resolve that problem with simple summing everything when there's no match (index == 1) if (index != -1) { alNew.RemoveAt(index); alNewPoIle.RemoveAt(index); alNewCo.RemoveAt(index); } else { ArrayList alTemp = new ArrayList(); decimal varAkcjeSuma = 0; for (int j = 0; j < alNew.Count; j ++) { string akcjeInId = (string) alNewCo[j]; decimal akcjeCena = (decimal) alNewPoIle[j]; decimal akcjeIlosc = (decimal) alNew[j]; if (tempAkcjeInId == akcjeInId && akcjeCena == varAkcjeCena) { alTemp.Add(j); varAkcjeSuma = varAkcjeSuma + akcjeIlosc; } } if (varAkcjeSuma == varAkcjeIlosc) { for (int j = alTemp.Count -1 ; j >=0 ; j --) { int tempIndex = (int) alTemp[j]; alNew.RemoveAt(tempIndex); alNewPoIle.RemoveAt(tempIndex); alNewCo.RemoveAt(tempIndex); } } But it only works if certain conditions are met, and fails for the rest.

    Read the article

  • Mixed Table Type with other types as parameters to Stored Procedured c#

    - by amemak
    Hi, I am asking about how could i pass multi parameters to a stored procedure, one of these parameters is user defined table. When I tried to do it it shows this error: INSERT INTO BD (ID, VALUE, BID) values( (SELECT t1.ID, t1.Value FROM @Table AS t1),someintvalue) here @Table is the user defined table parameter. Msg 116, Level 16, State 1, Procedure UpdateBD, Line 12 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS. Msg 109, Level 15, State 1, Procedure UpdateBD, Line 11 There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement. Thank you

    Read the article

  • How can I replace only the last occurence of an number in a string with php?

    - by Shawn
    How would you change this: a-10-b-19-c into something like this: a-10-b-20-c using regular expressions in PHP? The only solution I've found so far is: reverse the original string - "c-91-b-01-a" find the first number - "91" reverse it - "19" turn in into a number (parseInt) - 19 add 1 to it (+1) - 20 turn it into a string again (toString) - "20" reverse it again - "02" replace the original match with this new number - "c-02-b-01-a" reverse the string - "a-10-b-20-c" I was hoping someone on SO would have a simpler way to do this... Anyone?

    Read the article

  • Search object array for matching possible multiple values using different comparison operators

    - by Sparkles
    I have a function to search an array of objects for a matching value using the eq operator, like so: sub find { my ( $self, %params ) = @_; my @entries = @{ $self->{_entries} }; if ( $params{filename} ) { @entries = grep { $_->filename eq $params{filename} } @entries; } if ( $params{date} ) { @entries = grep { $_->date eq $params{date} } @entries; } if ( $params{title} ) { @entries = grep { $_->title eq $params{title} } @entries; } .... I wanted to also be able to pass in a qr quoted variable to use in the comparison instead but the only way I can think of separating the comparisons is using an if/else block, like so: if (lc ref($params{whatever}) eq 'regexp') { #use =~ } else { #use eq } Is there a shorter way of doing it? Because of reasons beyond my control I'm using Perl 5.8.8 so I can't use the smart match operator. TIA

    Read the article

  • Redirect www.example.com/apple to food.example.com/fruits/apple

    - by Senthil
    I want to redirect users from www.example.com/apple to http://food.example.com/fruits/apple Note: This is a hardcoded redirection. Even a mapping if you will. "apple" will not be substituted with anything else. Nothing in the two URLs will change except for the domain of course. So there is no need for a regular expression to match the "apple" or anything else. There is already dozens of RewriteCond and RewriteRule things in the .htaccess file. I do not want them to be affected. This redirection is independent of those. I have access to the .htaccess file at the root of www.example.com and the httpd.conf What code should I put in .htaccess in order to achieve this? Or should I change the httpd.conf?

    Read the article

  • Regular Expression - capturing contents of <select>

    - by joey mueller
    I'm trying to use a regular expression to capture the contents of all option values inside an HTML select element For example, in: <select name="test"> <option value="blah">one</option> <option value="mehh">two</option> <option value="rawr">three</option> </select> I'd like to capture one two and three into an array. My current code is var pages = responseDetails.responseText.match(/<select name="page" .+?>(?:\s*<option .+?>([^<]+)<\/option>)+\s*<\/select>/); for (var c = 0; c<pages.length; c++) { alert(pages[c]); } But it only captures the last value, in this case, "three". How can I modify this to capture all of them? Thanks!

    Read the article

  • How to implement a good system for login/out into a webapp

    - by Brandon Wang
    I am one of the developers at PassPad, a secure password generator and username storage system. We're still working on it, but I have a few questions on the best way to implement a secure login/out system. Right now, what we plan on doing is to have the login system save a cookie with the username and a session key, and that's all that serves as authentication. The server verifies the two to match. Upon login/out a new key is created. This is a security-related webapp and while we don't actually store any information that might make the user queasy, because it is security-oriented it makes it a necessity for us to at least appear secure in a way that the user would be happy with. Is there a better way to implement a login/out system in PHP? Preferably it won't take too much coding time or server resources. Is there anything else I need to implement, like brute-force protection, etc? How would I go about that?

    Read the article

  • Push origin master error on new repository.

    - by thaiyoshi
    I just started using git with github. I followed their instructions and ran into errors on the last step. I'm checking in an existing directory that isn't currently source-controlled (project about a week old). Other than that, my use case should be pretty run of the mill. Here's what's happening: $ git push origin master error: src refspec master does not match any. fatal: The remote end hung up unexpectedly error: failed to push some refs to '[email protected]:{username}/{projectname}.git' Github's instructions: Global setup: Download and install Git git config --global user.name "Your Name" git config --global user.email {username}@gmail.com Next steps: mkdir projectname cd projectname git init touch README git add README git commit -m 'first commit' git remote add origin [email protected]:{username}/{projectname}.git git push origin master

    Read the article

  • Get domain name (not subdomain) in php

    - by Cyclone
    I have a URL which can be any of the following formats: http://example.com https://example.com http://example.com/foo http://example.com/foo/bar www.example.com example.com foo.example.com www.foo.example.com foo.bar.example.com http://foo.bar.example.com/foo/bar example.net/foo/bar Essentially, I need to be able to match any normal URL. How can I extract example.com (or .net, whatever the tld happens to be. I need this to work with any TLD.) from all of these via a single regex? This is in PHP. Thanks for the help!

    Read the article

  • Unable to install Maven: "JAVA_HOME is set to an invalid directory"

    - by hello_world_infinity
    I followed the Maven tutorial to the letter but I still can't get Maven installed. When I run the following in command prompt: E:\Documents and Settings\zach>mvn --version I get: 'mvn' is not recognized as an internal or external command, operable program or batch file. I navigated to the maven install folder and ran mvn --version and got: E:\java resources\apache-maven-2.2.0\bin>mvn --version ERROR: JAVA_HOME is set to an invalid directory. JAVA_HOME = "E:\Sun\SDK\jdk\bin" Please set the JAVA_HOME variable in your environment to match the location of your Java installation but when I run java -version I get: java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode) So I do have Java installed. Anyone know what the problem is?

    Read the article

  • iPhone SDK Nested For Loop performance

    - by Skeep
    Hi All, I have a NSArray of string id and a NSDictionary of NSDictionary objects. I am currently looping through the string id array to match the id value in the NSDictionary. There are around 200 NSDictionary objects and only 5 or so string ID. My current code is such: for (NSString *Str in aArr) { for (NSDictionary *a in apArr) { if ([a objectForKey:@"id"] == Str) { NSLog(@"Found!"); } } } The performance of the above code is really slow and I was wondering if there is a better way to do this?

    Read the article

  • How do I run a vim script that alters the current buffer?

    - by Dan
    I'm trying to write a beautify.vim script that makes C-like code adhere to a standard that I can easily read. My file contains only substitution commands that all begin with %s/... However, when I try to run the script with my file open, in the manner :source beautify.vim, or :runtime beautify.vim, it runs but all the substitute commands state that their pattern wasn't found (patterns were tested by entering them manually and should work). Is there some way to make vim run the commands in the context of the current buffer? beautify.vim: " add spaces before open braces sil! :%s/\%>1c>\s\@<!{/ {/g " beautify for sil! :%s/for *( *\([^;]*\) *; *\([^;]*\) *; *\([^;]*\) *)/for (\1; \2; \3)/ " add spaces after commas sil! :%s/,\s\@!/, /g In my tests the first :s command should match (it matches when applied manually).

    Read the article

  • how to compare/validate sql schema

    - by Ron Harlev
    I'm looking for a way to validate the SQL schema on a production DB after updating an application version. If the application does not match the DB schema version, there should be a way to warn the user and list the changes needed. Is there a tool or a framework (to use programatically) with built-in features to do that? Or is there some simple algorithm to run this comparison? Update: Red gate lists "from $395". Anything free? Or more foolproof than just keeping the version number?

    Read the article

  • Will the URL /nosuchpage get routed via my ASP.NET MVC application?

    - by Gary McGill
    [I'm trying to figure out the reason why I'm having another problem, and this question is part of the puzzle.] I have an MVC 2 website that has routing set up so that URLs such as /Customer/23/Order/47 get handled by various controllers. I do not have a rule that would match, for example, /nosuchpage and in my Cassini environment a request for that URL will trigger my Application_Error code, which lets me log the error and show a friendly response. However, when I deployed this website on IIS7 using integrated mode, my Application_Error is not triggered, and IIS shows its own 404 message. No matter what I've tried, I can't get Application_Error to fire. Now I'm thinking: is the reason it doesn't fire because the request is not getting routed via my application? Either because I didn't explicitly set up a catch-all route, or because the file-extension fools it into thinking it should use the "static file handler" (whatever that is)? Should I expect my Application_Error to be invoked?

    Read the article

  • How to deny payment via PayPal IPN?

    - by Nick
    Hello all, I need to create dynamic 'Pay Now' buttons on my site, and PayPal says the way to do this is via an HTML FORM with preset variables for the price, currency, and item of the purchase. I use PayPal IPN to notify me when a payment has complete. However, what's to stop someone from modifying the query parameters of the Pay Now button to change the price? Some people have told me to redirect the button through a PHP file that sends you to a PayPal payment page with the parameters in place, but the price could just as easily be manipulated in the Web browser's address bar. My question is, how can I deny a payment if the information I receive from PayPal's IPN service is invalid (if the price doesn't match our records)? I'm quite confused and couldn't find any documentation on what I'm looking for. Hopefully, you guys can help. Thanks!

    Read the article

  • Javascript substrings multiline replace by RegExp

    - by Radek Šimko
    Hi, I'm having some troubles with matching a regular expression in multi-line string. <script> var str="Welcome to Google!\n"; str = str + "We are proud to announce that Microsoft has \n"; str = str + "one of the worst Web Developers sites in the world."; document.write(str.replace(/.*(microsoft).*/gmi, "$1")); </script> http://jsbin.com/osoli3/3/edit As you may see on the link above, the output of the code looks like this: Welcome to Google! Microsoft one of the worst Web Developers sites in the world. Which means, that the replace() method goes line by line and if there's no match in that line, it returns just the whole line... Even if it has the "m" (multiline) modifier...

    Read the article

  • Finding the index of a queue that holds a member of a containing object for a given value

    - by Luke Mcneice
    I have a Queue that contains a collection of objects, one of these objects is a class called GlobalMarker that has a member called GlobalIndex. What I want to be able to do is find the index of the queue where the GlobalIndex contains a given value (this will always be unique). Simply using the Contains method shown below returns a bool. How can I obtain the queue index of this match? RealTimeBuffer .OfType<GlobalMarker>() .Select(o => o.GlobalIndex) .Contains(INT_VALUE);

    Read the article

  • Can I mix static and shared-object libraries when linking?

    - by SiegeX
    I have a C project that produces ten executables, all of which I would like to be statically linked. The problem I am facing is that one of these executables uses a 3rd-party library of which only the shared-object version is available. If I pass the -static flag to gcc, ld will error saying it can't find the library in question (I presume it's looking for the .a version) and the executable will not be built. Ideally, I would like to be able to tell 'ld' to statically link as much as it can and fail over to the shared object library if a static library cannot be found. In the interium I tried something like gcc -static -lib1 -lib2 -shared -lib3rdparty foo.c -o foo.exe in hopes that 'ld' would statically link in lib1 and lib2 but only have a run-time dependence on lib3rdparty. Unfortunatly, this did not work as I intended; instead the -shared flag overwrote the -static flag and everything was compiled as shared-objects. Is statically linking an all-or-nothing deal, or is there some way I can mix and match?

    Read the article

  • MYOB Service Sales Import

    - by sjw
    I have developed an export file from our Job Management system that I want to be able to import into MYOB Accounting Plus v18.5. The file is generated without issue and I have included every single field to make it easy for upload (i.e. Match All matches every field) The problem I am having is no matter what I do, I cannot get the sales to import... Every time, no matter what I do or how I create the customer card comes back with: Error -190: Customer not found. Sale invoice not imported. I have tried matching using - co./Last Name, Card ID & Record ID and every time I get the same error. I have created a single customer with a simply Co./Last Name, Card ID & Record ID and still, when I try to import using these same fields exactly matched, I get the same error...

    Read the article

  • Bottom of page gets cut off in Safari

    - by VUELA
    I can't figure out why this page: http://wohf.squarespace.com/newsletter/ gets cut off at the bottom in safari, seems to work fine in all other browsers (as far as I found so far)!! I am using some jquery and css for the sidebar and the content to match heights and for the canvas to run top to bottom with the footer always at the very bottom of the page. everything is working (as far as I can tell so far) on the rest of the site, the problem is only on this newsletter page and only in safari. Can anyone see the problem?

    Read the article

< Previous Page | 156 157 158 159 160 161 162 163 164 165 166 167  | Next Page >