Search Results

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

Page 182/269 | < Previous Page | 178 179 180 181 182 183 184 185 186 187 188 189  | Next Page >

  • Loop function works first time, not second time

    - by user1483101
    I'm creating a parsing program to look for certain strings in a a text file and count them. However, I'm having some trouble with one spot. def callbrowse(): filename = tkFileDialog.askopenfilename(filetypes = (("Text files", "*.txt"),("HTML files", ".html;*.htm"),("All files", "*.*"))) print filename try: global filex global writefile filex = open(filename, 'r') print "Success!!" print filename except: print "Failed to open file" ######This returns the correct count only the first time it is run. The next time it ######returns 0. If the browse button is clicked again, then this function returns the ######correct count again. def count_errors(error_name): count = 0 for line in filex: if error_name == "CPU > 79%": stringparse = "Utilization is above" elif error_name == "Stuck touchscreen": stringparse = "Stuck touchscreen" if re.match("(.*)" + "Utilization is above" + "(.*)",line): count = count + 1 return count Thanks for any help. I can't seem to get this to work right.

    Read the article

  • Changing populated DataTable column data types

    - by TonE
    Hi, I have a System.Data.DataTable which is populated by reading a CSV file which sets the datatype of each column to string. I want to append the contents of the DataTable to an existing database table - currently this is done using SqlBulkCopy with the DataTable as the source. However, the column data types of the DataTable need to be changed to match the schema of the target database table, handling null values. I am not very familiar with ADO.NET so have been search for a clean way of doing this? Thanks.

    Read the article

  • jQuery: set the width of a textarea?

    - by AP257
    What it says on the tin: how do I set the width of a textarea in jQuery? I want to set the width of a textarea to match the width of a particular image. Using .width() works for setting the width of an image, but not of a textarea. $(document).ready(function() { var width = $("#my_image").width(); $("#another_image").width(width); // works $("#my_textarea").width(width); // fails }); How do I set the width of a textarea?

    Read the article

  • javascript regular expressions

    - by Zhasulan Berdybekov
    Help me with regular expressions. I need to check the text on the hour and minute. That is the first case, the text can be from 0 to 12. In the second case, the text can be from 1 to 60. this is my code: var hourRegEx = /^([0-9]{2})$/; //You can fix this line of code? $(document).ready( function(){ $('form.form').submit(function(){ if( $('input.hour').val().match(hourRegEx) ){ return true; } return false; }); }); In my case, the code says that, for example 52, too, the correct answer

    Read the article

  • Python: Matching & Stripping port number from socket data

    - by tobywuk
    Hello, I have data coming in to a python server via a socket. Within this data is the string '<port>80</port>' or which ever port is being used. I wish to extract the port number into a variable. The data coming in is not XML, I just used the tag approach to identifying data for future XML use if needed. I do not wish to use an XML python library, but simply use something like regexp and strings. What would you recommend is the best way to match and strip this data? I am currently using this code with no luck: p = re.compile('<port>\w</port>') m = p.search(data) print m Thank you :)

    Read the article

  • What does the R function `poly` really do?

    - by merlin2011
    I have read through the manual page ?poly (which I admit I did not completely comphrehend) and also read the description of the function in book Introduction to Statistical Learning. My current understanding is that a call to poly(horsepower, 2) should be equivalent to writing horsepower + I(horsepower^2). However, this seems to be contradicted by the output of the following code. library(ISLR) summary(lm(mpg~poly(horsepower,2), data=Auto))$coef summary(lm(mpg~horsepower+I(horsepower^2), data=Auto))$coef Output: Estimate Std. Error t value Pr(>|t|) (Intercept) 23.44592 0.2209163 106.13030 2.752212e-289 poly(horsepower, 2)1 -120.13774 4.3739206 -27.46683 4.169400e-93 poly(horsepower, 2)2 44.08953 4.3739206 10.08009 2.196340e-21 Estimate Std. Error t value Pr(>|t|) (Intercept) 56.900099702 1.8004268063 31.60367 1.740911e-109 horsepower -0.466189630 0.0311246171 -14.97816 2.289429e-40 I(horsepower^2) 0.001230536 0.0001220759 10.08009 2.196340e-21 My question is, why does the output not match, and what is poly really doing?

    Read the article

  • How to test if Scala combinator parser matches a string

    - by W.P. McNeill
    I have a Scala combinator parser that handles comma-delimited lists of decimal numbers. object NumberListParser extends RegexParsers { def number: Parser[Double] = """\d+(\.\d*)?""".r ^^ (_.toDouble) def numbers: Parser[List[Double]] = rep1sep(number, ",") def itMatches(s: String): Boolean = parseAll(numbers, s) match { case _: Success[_] => true case _ => false } } The itMatches function returns true when given a string that matches the pattern. For example: NumberListParser.itMatches("12.4,3.141") // returns true NumberListParser.itMatches("bogus") // returns false Is there a more terse way to do this? I couldn't find one in the documentation, but my function sees a bit verbose, so I wonder if I'm overlooking something.

    Read the article

  • can function return 0 as reference

    - by helloWorld
    I have this snippet of the code Account& Company::findAccount(int id){ for(list<Account>::const_iterator i = listOfAccounts.begin(); i != listOfAccounts.end(); ++i){ if(i->nID == id){ return *i; } } return 0; } Is this right way to return 0 if I didn't find appropriate account? cause I receive an error: no match for 'operator!' in '!((Company*)this)->Company::findAccount(id)' I use it this way: if(!(findAccount(id))){ throw "hey"; } thanks in advance

    Read the article

  • Obtaining frame pointer in C

    - by assketchum
    I'm trying to get the FP in my C program, I tried two different ways, but they both differ from what I get when I run GDB. The first way I tried, I made a protocol function in C for the Assembly function: int* getEbp(); and my code looks like this: int* ebp = getEbp(); printf("ebp: %08x\n", ebp); // value i get here is 0xbfe2db58 while( esp <= ebp ) esp -= 4; printf( "ebp: %08x, esp" ); //value i get here is 0xbfe2daec My assembly code getEbp: movl %ebp, %eax ret I tried making the prototype function to just return an int, but that also doesn't match up with my GDB output. We are using x86 assembly. EDIT: typos, and my getEsp function looks exactly like the other one: getEsp: movl %esp, %eax ret

    Read the article

  • Is there a way to redirect ONLY stderr to stdout (not combine the two) so it can be piped to other programs

    - by James K
    I'm working in a Windows CMD.EXE environment and would like to change the output of stdout to match that of stderr so that I can pipe error messages to other programs without the intermediary of a file. I'm aware of the 2>&1 notation, but that combines stdout and stderr into a single stream. What I'm thinking of would be something like this: program.exe 2>&1 | find " " But that combines stdout and stderr just like: program.exe | find " " 2>&1 I realize that I could do... program 2>file type file | find " " del file But this does not have the flexibility and power of a program | find " " sort of notation. Doing this requires that program has finished with it's output before that output can be processed.

    Read the article

  • Why does String.Equals(Object obj) check to see if this == null?

    - by m-y
    // Determines whether two strings match. [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] public override bool Equals(Object obj) { //this is necessary to guard against reverse-pinvokes and //other callers who do not use the callvirt instruction if (this == null) throw new NullReferenceException(); String str = obj as String; if (str == null) return false; if (Object.ReferenceEquals(this, obj)) return true; return EqualsHelper(this, str); } The part I don't understand is the fact that it is checking for the current instance, this, against null. The comment is a bit confusing, so I was wondering what does that comment actually mean? Can anyone give an example of how this could break if that check was not there, and does this mean that I should also place that check in my classes?

    Read the article

  • Function Composition in Haskell

    - by Watts
    I have a function that takes 3 functions and switches the types and combine to make a new function. For example a test case call would be : (chain init tail reverse ) "Haskell!" the output should be lleksa I've tried to do this problem a few different ways including using the map function but I kept getting association problems. so i did chain :: Ord a => [a] -> a chain f g h x = f.g.h$x my error is Couldn't match expected type[t0->t1->t2->a0] When I type the problem directly into prelude like replacing f, g, h, x with the values it comes out right Is there even a way to do three functions, I've only seen two in examples

    Read the article

  • Regular expression problem

    - by sYl3r
    Hi, How can I search a whole string for a specific match. It'll contain both characters with int or decimal numbers eg A12B32.25C-456D-75.E75 I'll know that this will start with A and ends with E I think I can use "^" and "$" right? but i'm bit lost in other parts to check for character and int or decimal. I'll be glad if you can give the regex and explain it a bit :). PS. D-75. is not mistyped... Thanks in advance.

    Read the article

  • can't compile min_element in c++

    - by Vincenzo
    This is my code: #include <algorithm> #include <vector> #include <string> using namespace std; class A { struct CompareMe { bool operator() (const string*& s1, const string*& s2) const { return true; } }; void f() { CompareMe comp; vector<string*> v; min_element(v.begin(), v.end(), comp); } }; And this is the error: error: no match for call to ‘(A::CompareMe) (std::string*&, std::string*&)’ test.cpp:7: note: candidates are: bool A::CompareMe::operator()(const std::string*&, const std::string*&) const I feel that there is some syntax defect, but can't find out which one. Please, help!

    Read the article

  • What the best way to parse and find The specific data

    - by Khemlall Mangal
    Ok i have an issue i want to resolve. I have the following log file, and i want to parse it and find the errors and then compare them to user expected results and if it doesnt match then error or else pass.... the part that i am having trouble with is finding error within the log.... So in this example, within the log starting point is MASTER EXCLUSIONS:[ALL_EXCLUSIONS] errors: Then error can be in two format as show below. what the regular expressssion orcode that i can use to parse this and get pull out these error from count of 1 to end and i will just be able to take the array value for exammple results[1] - compare if == myresults[1] as an exmple.... outputting it in a file is ok too

    Read the article

  • partial string matching - R

    - by DonDyck
    I need to write a query in R to match partial string in column names. I am looking for something similar to LIKE operator in SQL. For e.g, if I know beginning, middle or end part of the string I would write the query in format: LIKE 'beginning%middle%' in SQL and it would return matching strings. In pmatch or grep it seems I can only specify 'beginning' , 'end' and not the order. Is there any similar function in R that I am looking for? For example, say I am looking in the vector: y<- c("I am looking for a dog", "looking for a new dog", "a dog", "I am just looking") Lets say I want to write a query which picks "looking for a new dog" and I know start of the string is "looking" and end of string is "dog". If I do a grep("dog",y) it will return 1,2,3. Is there any way I can specify beginning and end in grep?

    Read the article

  • how to input into string array in c++

    - by Artemis
    i want to declare an array of strings and want to input string via CIN command but it gives me an error i am trying to do this name1 name2 name3 . . . and so on... i am entering string to an array dynamical means input from cin for CIN i use the following code like if i use 3 names to be entered string arr[3]; for (int x=0;x<3;x++) { cout<<"enter name"<<x<<" "; cin<<arr[x]; } for(int z=0;z<3;z++) cout<<arr[z]; it gives an error NO MATCH FOR CIN....

    Read the article

  • Regex for removing an item from a comma-separated string?

    - by ingredient_15939
    Say I have a string like this: "1,2,3,11" A simple regex like this will find a number in the string: (?<=^|,)1(?=,|$) - this will correctly find the "1" (ie. not the first "1" in "11"). However, to remove a number from the string, leaving the string properly formatted with commas in between each number, I need to include one adjacent comma only. For example, matching 1,, 2, or ,11. So the trick is to match one comma, on either side of the number, but to ignore the comma on the opposite side (if there is one). Can someone help me with this?

    Read the article

  • MySql. What is there error on this insert+select+where statement?

    - by acidzombie24
    What is wrong with this statement? It works with sqlite and MS sql (last time i tested it) I would like a select unless there is no match with name or email. Then i would like to insert. I have it as one statement because its easy to keep concurrent safe as one statement. (its not that complex of a statement). INSERT INTO `user_data` ( `last_login_ip`, `login_date`, ...) SELECT @0, @14 WHERE not exists (SELECT * FROM `user_data` WHERE `name` = @15 OR `unconfirmed_email` = @16 LIMIT 1); Exception You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE not exists (SELECT * FROM `user_data` WHERE `name` = 'thename' OR `unconfirmed' at line 31

    Read the article

  • Removing control / special characters from log file

    - by digitalsky
    I have a log file captured by tclsh which captures all the backspace characters (ctrl-H, shows up as "^H") and color-setting sequences (eg. ^[[32m .... ^[[0m ). What is an efficient way to remove them? ^[...m This one is easy since, I can just do "sed -i /^[.*m//g" to remove them ^H Right now I have "sed -i s/.^H//", which "applies" a backspace, but I have to keep looping this until there are no more backspaces. while [ logfile == `grep -l ^H logfile` ]; do sed -i s/.^H// logfile ; done; "sed -i s/.^H//g" doesn't work because it would match consecutive backspaces. This process takes 11 mins for my log file with ~6k lines, which is too long. Any better ways to remove the backspace?

    Read the article

  • Longest substring in a large set of strings

    - by user1516492
    I have a huge fixed library of text strings, and a frequently changing input string s. I need to find the longest matching substring from any string in the library to s, starting from the beginning of string s, in minimal time. In a perfect world, I would also return the next longest match from the library, and the next best, and so on. This is not the longest common string problem - I'm not looking for the longest common string for all the strings in the library... I just need a pairwise best substring between s and each string in the vast library as fast as possible.

    Read the article

  • display alert when mouse hovers over word in text

    - by user1672790
    I have been struggling with this for a few days. I need somebody to steer me in the right direction. I have been searching on the web. I am not sure if I took the right approach. What I need is that each time a person hovers over a particular keyword, it should display an alert box. In this example the word is else. When I run the code it does not give any errors and does not display anything when mouse hovers on the word. function on_func2() { var searchString = 'else'; var elements = document.getElementById('paragraph2'); for (var i = 0; i < elements.length; i++) { if (elements[i].innerHTML.indexOf(searchString) !== -1) { alert('Match'); break; } } }

    Read the article

  • Looking for another regex explanation

    - by Sam
    In my regex expression, I was trying to match a password between 8 and 16 character, with at least 2 of each of the following: lowercase letters, capital letters, and digits. In my expression I have: ^((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,16})$ But I don't understand why it wouldn't work like this: ^((?=\d)(?=[a-z])(?=[A-Z])(?=\d)(?=[a-z])(?=[A-Z]){8,16})$ Doesnt ".*" just meant "zero or more of any character"? So why would I need that if I'm just checking for specific conditions? And why did I need the period before the curly braces defining the limit of the password? And one more thing, I don't understand what it means to "not consume any of the string" in reference to "?=".

    Read the article

  • read integers from a file into a vector in C++

    - by user2922063
    I am trying to read an unknown number of double values stored on separate lines from a text file into a vector called rainfall. My code won't compile; I am getting the error no match for 'operator>>' in 'inputFile >> rainfall' for the while loop line. I understand how to read in from a file into an array, but we are required to use vectors for this project and I'm not getting it. I appreciate any tips you can give on my partial code below. vector<double> rainfall; // a vector to hold rainfall data // open file ifstream inputFile("/home/shared/data4.txt"); // test file open if (inputFile) { int count = 0; // count number of items in the file // read the elements in the file into a vector while ( inputFile >> rainfall ) { rainfall.push_back(count); ++count; } // close the file

    Read the article

  • MyEntity.findAllByNameNotLike('bad%')

    - by Richard Paul
    I'm attempting to pull up all entities that have a name that doesn't partially match a given string. MyEntity.findAllByNameNotLike('bad%') This gives me the following error: No such property: nameNot for class: MyEntity Possible solutions: name" type="groovy.lang.MissingPropertyException" I had a quick look at the criteria style but I can't seem to get that going either, def results = MyEntity.withCritieria { not(like('name', 'bad%')) } No signature of method: MyEntity.withCritieria() is applicable for argument types: (MyService$_doSomething_closure1) Ideally I would like to be able to apply this restriction at the finder level as the database contains a large number of entities that I don't want to load up and then exclude for performance reasons. [grails 1.3.1]

    Read the article

< Previous Page | 178 179 180 181 182 183 184 185 186 187 188 189  | Next Page >