Search Results

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

Page 22/269 | < Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >

  • replace characters which do not match with the ones in a regex

    - by Cristian Boariu
    Hi, I have this regex: private static final String SPACE_PATH_REGEX ="[a-z|A-Z|0-9|\\/|\\-|\\_|\\+]+"; I check if my string matches this regex and IF NOT, i want to replace all characters which are not here, with "_". I've tried like: private static final String SPACE_PATH_REGEX_EXCLUDE = "[~a-z|A-Z|0-9|\\/|\\-|\\_|\\+]+"; if (myCompanyName.matches(SPACE_PATH_REGEX)) { myNewCompanySpaceName = myCompanyName; } else{ myNewCompanySpaceName = myCompanyName.replaceAll( SPACE_PATH_REGEX_EXCLUDE, "_"); } but it does not work..., so in the 2nd regex "~" seems to not omit the following chars. Any idea?

    Read the article

  • Partial match in MaskFormatter for jFormattedTextField

    - by Toto
    How do I set up the MaskFormatter and the JFormattedTextField in order to allow partial matches? For example: I want the user to be able to enter numbers with this mask "## ###### ####", so if the user enters '123456789123' the formatter changes it to '12 345678 9123'. However, I also want the user to be able to enter '12346578', be converted to '12 345678' and still be a valid value (so I can get it using jFormatedTextField1.getValue()) This is part of my code (most of it generated by Netbeans): private javax.swing.JFormattedTextField jFormattedTextField1; // ... try { jFormattedTextField1.setFormatterFactory(new DefaultFormatterFactory(new MaskFormatter("## ###### ####"))); } catch (java.text.ParseException ex) { ex.printStackTrace(); } I've tried setting the focusLostBehavior to PERSIST so the value is not cleard after exiting the jFormattedTextField1, but that way I get a null when using the calling jFormattedTextField1.getValue()

    Read the article

  • HQL(hibernate) timestamp range match

    - by Saky
    I need to write a query to get an object between a range of time, currently the query looks like this: Timestamp from = ... Timestamp to = ... getHibernateTemplate().find("from " + Person.class.getName() + " ml where ml.lastModifiedOn>="+from.toString()+" and m1.lastModifiedOn<=" + to.toString()); However, this doesnot work for obvious reasons. How can I format the timestamp to be acceptable by the query. org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 16 near line 1, column 123 [from Person ml where ml.lastModifiedOn=2010-02-12 16:00:21.292 and m1.lastModifiedOn

    Read the article

  • SVN Repository folders don't match my solution folder structure in Visual Studio or folder structure

    - by Carlos
    I have a .NET solution which was badly organised, so I moved some projects around to appropriate folders. In the solution, I simply fixed the paths to the new locations, and everything is working in my working copy. I used AnkhSVN to commit the solution to the repository, which worked out fine as well. However, when I look in the repo explorer, the folders inside are organised in the old way. What do I need to do?

    Read the article

  • My presentation layer does not match my model layer even though I have no animations

    - by Kevin McCullough
    On iPhone I have a CALayer that I animate via Core Animation. Then at some point I change view controllers. I then return to the view controller with the CALayer and in viewWillAppear: I set the frame and position properties on my layer to move it back to its starting point. Setting these properties changes the model layer but the presentation layer still has the old values and its presentation layer does not update until the next animation I play. In the CA Programming guide it says "You can query an instance of CALayer for its corresponding presentation layer while an animation transaction is in process." Which, to me, implies that the presentation layer should only be different from the model layer during an animation. But there are no animations currently running. I even used kCATransactionDisableActions to ensure that when I set the position property an implicit animation is not started. Does anyone know why my presentation and model layers are out of sync? Thanks.

    Read the article

  • Trying to find a match in two strings - Python

    - by Jacob Mammoliti
    I have a user inputting two strings and then I want to check if there are any similar characters and if there is, get the position where the first similarity occurs, without using the find or index function. Below is what I have so far but I doesn't fully work. With what I have so far, I'm able to find the similarities but Im not sure how to find the position of those similarities without using the index function. string_a = "python" string_b = "honbe" same = [] a_len = len(string_a) b_len = len(string_b) for a in string_a: for b in string_b: if a == b: same.append(b) print (same) Right now the output is: ['h', 'o', 'n'] So basically what I am asking is, how can I find the position of those characters without using the Python Index function?

    Read the article

  • Regular Expression doesn't match

    - by dododedodonl
    Hi All, I've got a string with very unclean HTML. Before I parse it, I want to convert this: <TABLE><TR><TD width="33%" nowrap=1><font size="1" face="Arial"> NE </font> </TD> <TD width="33%" nowrap=1><font size="1" face="Arial"> DEK </font> </TD> <TD width="33%" nowrap=1><font size="1" face="Arial"> 143 </font> </TD> </TR></TABLE> in NE DEK 143 so it is a bit easier to parse. I've got this regular expression (RegexKitLite): NSString *str = [dataString stringByReplacingOccurrencesOfRegex:@"<TABLE><TR><TD width=\"33%\" nowrap=1><font size=\"1\" face=\"Arial\">(.+?)<\\/font> <\\/TD>(.+?)<TD width=\"33%\" nowrap=1><font size=\"1\" face=\"Arial\">(.+?)<\\/font> <\\/TD>(.+?)<TD width=\"33%\" nowrap=1><font size=\"1\" face=\"Arial\">(.+?)<\\/font> <\\/TD>(.+?)<\\/TR><\\/TABLE>" withString:@"$1 $3 $5"]; I'm no an expert in Regex. Can someone help me out here? Regards, dodo

    Read the article

  • Regexp match in Java

    - by tinti
    Regexp in Java I want to make a regexp who do this verify if a word is like [0-9A-Za-z][._-'][0-9A-Za-z] example for valid words A21a_c32 daA.da2 das'2 dsada ASDA 12SA89 non valid words dsa#da2 34$ Thanks

    Read the article

  • grep + add time out after some time if not find the relevant match

    - by yael
    Dear friends I use the following command syntax to search params in my script grep -qsRw -m1 "any_param" /dir/..../ Some times the search take avery long time The question is how to add time out to grep command For example after 20 seconds grep will break out If it not illegal to add time out to grep , how it will possible on other way? THX Yael

    Read the article

  • Blackberry JDE generating bad .jad file (does not match compiled .cod file)

    - by matkas
    I Have a BB application that gets compiled into 3 siblings cod file. ( actualy one cod fil contaning 3 sub cod files). app.cod |--app.cod |--app-1.cod |--app-2.cod which is normal. the jad refers to those 3 inner .cod files. Now I have add some feature to my app, it is getting a little bit bigger. the jad now refers to 4 inner .cod files. but there is still 3 inside the app.cod that is generated. so I now still have app.cod |--app.cod |--app-1.cod |--app-2.cod but with the jad refering to app.cod app-1.cod app-2.cod AND app-3.cod. what is wrong the my compiled program? is it a bug from the JDE? I am using JDE 4.5.

    Read the article

  • Java, searching through folders to match a name

    - by Nick
    Hi folks, I using java to search for a file or folder that matches a specific case. For instance i want to search through all the files and folders and iterate through them as many times as necessary untill i find a result. The catch I searching for files and folders through a binary image of a file system. This means i doubt there are any preexisting classes such java.file.* to do it for me. If it helps i can tell you that i can tell the difference between files and folders easily enough. (a folder is flagged as 0x20) The only way i can think of is to do a standard loop and iterated several times but this limits me if a file or folder is several folders deep. All input greatly welcome

    Read the article

  • C++ match string in file and get line number

    - by Corey
    I have a file with the top 1000 baby names. I want to ask the user for a name...search the file...and tell the user what rank that name is for boy names and what rank for girl names. If it isn't in boy names or girl names, it tells the user it's not among the popular names for that gender. The file is laid out like this: Rank Boy-Names Girl-Names 1 Jacob Emily 2 Michael Emma . . . Desired output for input Michael would be: Michael is 2nd most popular among boy names. If Michael is not in girl names it should say: Michael is not among the most popular girl names Though if it was, it would say: Micheal is (rank) among girl names The code I have so far is below.. I can't seem to figure it out. Thanks for any help. #include <iostream> #include <fstream> #include <string> #include <cctype> using namespace std; void find_name(string name); int main(int argc, char **argv) { string name; cout << "Please enter a baby name to search for:\n"; cin >> name; /*while(!(cin>>name)) { cout << "Please enter a baby name to search for:\n"; cin >> name; }*/ find_name(name); cin.get(); cin.get(); return 0; } void find_name(string name) { ifstream input; int line = 0; string line1 = " "; int rank; string boy_name = ""; string girl_name = ""; input.open("/<path>/babynames2004.rtf"); if (!input) { cout << "Unable to open file\n"; exit(1); } while(input.good()) { while(getline(input,line1)) { input >> rank >> boy_name >> girl_name; if (boy_name == name) { cout << name << " is ranked " << rank << " among boy names\n"; } else { cout << name << " is not among the popular boy names\n"; } if (girl_name == name) { cout << name << " is ranked " << rank << " among girl names\n"; } else { cout << name << " is not among the popular girl names\n"; } } } input.close(); }

    Read the article

  • Regex optional match in python fails

    - by AaronG
    tickettypepat = (r'MIS Notes:.**(//p//)?.**') retype = re.search(tickettypepat,line) if retype: print retype.group(0) print retype.group(1) Given the input. MIS Notes: //p// Can anyone tell me why group(0) is MIS Notes: //p// and group(1) is returning as None?

    Read the article

  • Regex take too long to match the result

    - by Joe Ijam
    Hi all I have this regex pattern <(\d+)>(\d+\.\d+|\d{4}\-\d+\-\d+\s+\d{2}:\d{2}:\d{2})(?:\..*?)*\s+(ALER|NOTI) and this is my input (will not matched at all) <150>2010-12-29 18:11:30.883 -0700 192.168.2.145 80 192.168.2.87 2795 "-" "-" GET HTTP 192.168.2.145 HTTP/1.1 200 36200 0 1038 544 192.168.2.221 80 540 SERVER DEFAULT PASSIVE VALID /joomla/ "-" http://192.168.2.145/joomla/index.php?option=com_content&view=a be4d44e8f3986183a87991398c1c212e=1; be4d44e8f3986183a87991398c1c212e=1 This will return not matched result but it takes too long to output the result. Since i have a thousand of logs/inputs in a second, it should finish very fast for every single log/input. Sometime it reaches CPU 100%. Can anyone help me to solve this regex problem? Thanks

    Read the article

  • Regex browser version match

    - by Matic
    I have a string: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729) I want to know what version of Firefox is in the string (3.5.2). My current regex is: Firefox\/[0-9]\.[0-9]\.[0-9] and it returns Firefox/3.5.2 I only want it to return 3.5.2 from the Firefox version, not the other versions in the string. I already know the browser is Firefox.

    Read the article

  • Increase increment size to match GUID advantage

    - by TenaciousImpy
    Hi, I've been thinking of implementing this system, but can't help but feel there's a catch somewhere. One of the points of using GUID over incrementing int is that, in the future, if you were to merge databases together, you wouldn't have any clashes over the primary key/identifier. However, my approach is to set the increment size to X where X is the number of servers I'll most likely have in the future. Then, on each server, have the seed be an increment over the seed number on the previous server. That way, during merging, there would be no clashes with the primary key. Is this a safe, normal method or have I gone mental :)? Thanks

    Read the article

  • BigDecimal to_s does not match to_f

    - by Chris Bisignani
    Is the BigDecimal class broken? It seems like the following should never, ever occur: Note that a.to_f != a.to_s.to_f a.class = BigDecimal a.to_f = 18658.1072928 a.to_s = "10865.81072928" b.class = BigDecimal b.to_f = 10000.0 b.to_s = "10000.0" (a - b).to_f = 865.81072928 a.to_f - b.to_f = 8658.1072928 Any ideas as to what might be going wrong?

    Read the article

  • Match HTML tags in two strings using regex in Python

    - by jack
    I want to verify that the HTML tags present in a source string are also present in a target string. For example: >> source = '<em>Hello</em><label>What's your name</label>' >> verify_target(’<em>Hi</em><label>My name is Jim</label>') True >> verify_target('<label>My name is Jim</label><em>Hi</em>') True >> verify_target('<em>Hi<label>My name is Jim</label></em>') False

    Read the article

  • Python: using a regular expression to match one line of HTML

    - by skylarking
    This simple Python method I put together just checks to see if Tomcat is running on one of our servers. import urllib2 import re import sys def tomcat_check(): tomcat_status = urllib2.urlopen('http://10.1.1.20:7880') results = tomcat_status.read() pattern = re.compile('<body>Tomcat is running...</body>',re.M|re.DOTALL) q = pattern.search(results) if q == []: notify_us() else: print ("Tomcat appears to be running") sys.exit() If this line is not found : <body>Tomcat is running...</body> It calls : notify_us() Which uses SMTP to send an email message to myself and another admin that Tomcat is no longer runnning on the server... I have not used the re module in Python before...so I am assuming there is a better way to do this... I am also open to a more graceful solution with Beautiful Soup ... but haven't used that either.. Just trying to keep this as simple as possible...

    Read the article

  • Predicate<INT> match question

    - by Petr
    Hi, I do not understand how following code works. Specifically, I do not understand using of "return i<3". I would expect return i IF its < than 3. I always though that return just returns value. I could not even find what syntax is it. Second question, it seems to me like using anonymous method (delegate(int i)) but could be possible to write it with normal delegate pointing to method elsewere? Thanks List<int> listOfInts = new List<int> { 1, 2, 3, 4, 5 }; List<int> result = listOfInts.FindAll(delegate(int i) { return i < 3; });

    Read the article

< Previous Page | 18 19 20 21 22 23 24 25 26 27 28 29  | Next Page >