Search Results

Search found 17715 results on 709 pages for 'regular language'.

Page 70/709 | < Previous Page | 66 67 68 69 70 71 72 73 74 75 76 77  | Next Page >

  • Need to create regular expression in Javascript to check the valid conditional string

    - by user1796078
    I want to create the regular expression in javascript which will check the valid conditional string like -1 OR (1 AND 2) AND 1 -1 OR (1 AND 2) -1 OR 2 -1 OR 1 OR 1 -1 AND 1 AND 1 The string should not contain 'AND' and 'OR'. For example - 1 OR 2 AND 3 is invalid. -It should be (1 OR 2) AND 3 or 1 or (2 AND 3). I tried the following Regex. It works for most of the conditions but it is failing to check the above condition. /^(\s*\(\d+\s(AND|OR)\s\d+\)|\s*\d+)((\s*(AND|OR)\s*)(\(\d+\s(AND|OR)\s\d+\)|\s*\d+))*$/ Can anyone please help me to sort out the above problem.

    Read the article

  • Regular expression to truncate a String

    - by user470184
    To truncate a String here is what I'm using : String test1 = "this is test truncation 1.pdf"; String p1 = test1.substring(0, 10) + "..."; System.out.println(p1); The output is 'this is te...' How can I access the file name extension so that output becomes : 'this is te... pdf' I could use substring method to access the last three characters but other file extensions could be 4 chars in length such as .aspx Is there a regular expression I can use so that "this is test truncation 1.pdf" becomes "this is te... pdf"

    Read the article

  • Remove html code in a text with no regular expresion

    - by Blanca
    Hi! I am working in the indexation of feeds from Internet. I would like to remove tha html code which appears in some of them. I have used regular expression for the ones i have seen, but I would like to find some way to remove all of them automaticcally, because I don't know if I have seen all possible html code in my feeds. Is there any possibillity?? I add an example of things I would like to remove: /0831/oly_g_liukin_576.jpg" height="49" width="41" / BEIJING - AUGUST 15: Nastia Liukin of the... Thank you!

    Read the article

  • Regular Expression to capture the first <p> of HTML

    - by Program.X
    I have the following regular expression: (?:<(?<tag>\w*)>(?<text>.*)</\k<tag>>) I want it t grab the text within the first HTML element. eg. <p>This should capture</p>This shouldn't Works, but ... <p>This should capture</p><p>This shouldn't</p> Doesn't work. As you'd expect, it returns: This should capture</p><p>This shouldn't I'm racking my brains here. How can I just have it select the FIRST inner text? (I'm trying to be tag-agnostic, so <strong>This should match</strong> is equally appropriate, etc.)

    Read the article

  • regular expression for bit strings with even number of 1s

    - by equilibrium
    Let L= { w in (0+1)* | w has even number of 1s}, i.e. L is the set of all bit strings with even number of 1s. Which one of the regular expressions below represents L? A) (0*10*1)* B) 0*(10*10*)* C) 0*(10*1)* 0* D) 0*1(10*1)* 10* According to me option D is never correct because it does not represent the bit string with zero 1s. But what about the other options? We are concerned about the number of 1s(even or not) not the number of zeros doesn't matter. Then which is the correct option and why?

    Read the article

  • regular expression

    - by Altariste
    Hi, I need to find all invocations of some logging macros in the code. The macro invocation is of the form: DEBUG[1-5] ( "methodName: the logged message", arguments) But the new versions of the macros are prepending the name of the method automatically, so my task is to write a Python script that will remove the duplicate function names specified already by the programmer. I'm using the sub function from the re module. I plan to substitute the part indicated by || signs below : ||DEBUG[1-5] ("methodName: || the logged message", arguments) with simply DEBUG[1-5](" The problem is following: To find the expressions I want to substitute, I use the following regular expression: ((DEBUG | INFO | all other macros names )[1-5]*)\s*\(\"\w+: But it doesn't match the whole expression ( from DEBUG right to the colon ), but only the macro name, that is for example DEBUG5. Is my expression wrong or there is some quirk in the Python regex processing? ( maybe the fact that I use the DEBUG[1-5] as a subgroup has something to do with this? ) Help from anyone more knowledgable than me appreciated :).

    Read the article

  • Saving substrings using Regular Expressions

    - by user362971
    I'm new to regular expressions in Java (or any language, for that matter) and I'm wanting to do a find using them. The tricky part that I don't understand how to do is replace something inside the string that matches. For example, if the line I'm looking for is Person item6 [can {item thing [wrap]}] I'm able to write a regex that finds that line, but finding what the word "thing" is (as it may differ among different lines) is my problem. I may want to either replace that word with something else or save it in a variable for later. Is there any easy way to do this using Java's regex engine?

    Read the article

  • Splitting up input using regular expressions in Java

    - by Joe24
    I am making a program that lets a user input a chemical for example C9H11N02. When they enter that I want to split it up into pieces so I can have it like C9, H11, N, 02. When I have it like this I want to make changes to it so I can make it C10H12N203 and then put it back together. This is what I have done so far. using the regular expression I have used I can extract the integer value, but how would I go about get C10, H11 etc..? System.out.println("Enter Data"); Scanner k = new Scanner( System.in ); String input = k.nextLine(); String reg = "\\s\\s\\s"; String [] data; data = input.split( reg ); int m = Integer.parseInt( data[0] ); int n = Integer.parseInt( data[1] );

    Read the article

  • Python Regular Expression TypeError

    - by spaghettiwestern
    I am writing my first python program and I am running into a problem with regex. I am using regular expression to search for a specific value in a registry key. import _winreg import re key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{26A24AE4-039D-4CA4-87B4-2F83216020FF}") results=[] v = re.compile(r"(?i)Java") try: i = 0 while 1: name, value, type = _winreg.EnumValue(key, i) if v.search(value): results.append((name,value,type)) i += 1 except WindowsError: print for x in results: print "%-50s%-80s%-20s" % x I am getting the following error: exceptions.TypeError: expected string or buffer I can use the "name" variable and my regex works fine. For example if I make the following changes regex doesn't complain: v = re.compile(r"(?i)DisplayName") if v.search(name): Thanks for any help.

    Read the article

  • Using regular expressions with Dojo data.fetch?

    - by Dfowj
    I'm trying to use the below code to fetch a regular expression like this /[computer]{3,8}/(what i think is any words containing the letters in computer ranging from 3 to 8 letters long) from a database (which i know is being loaded correctly). When i fetch, i get 10 results, all the same word... "Adenauer" var base = "computer"; var baseRE = '/[' + base + ']{' + this.minLength + ',' + base.length + '}/'; this.dict.fetch({query: {word:baseRE}, onComplete: onLoadWords, onError: function(err) { console.log(err); }}); Any ideas what im doing wrong?

    Read the article

  • How can I improve this regular expression?

    - by Michael Haren
    I want a regular expression to match valid input into a Tags input field with the following properties: 1-5 tags Each tag is 1-30 characters long Valid tag characters are [a-zA-Z0-9-] input and tags can be separated by any amount of whitespace Here's what I have so far--it seems to work but I'm interested how it could be simplified or if it has any major flaws: \s*[a-zA-Z0-9-]{1,30}(\s+[a-zA-Z0-9-]{1,30}){0,4}\s* // that is: \s* // match all beginning whitespace [a-zA-Z0-9-]{1,30} // match the first tag (\s+[a-zA-Z0-9-]{1,30}){0,4} // match all subsequent tags \s* // match all ending whitespace Preprocessing the input to make the whitespace issue easier isn't an option (e.g. trimming or adding a space). If it matters, this will be used in javascript. Any suggestions would be appreciated, thanks!

    Read the article

  • Regular Expression repetition of class

    - by codersarepeople
    I am trying to figure out a regular expression for the following: <tr class="A">.*</tr><tr class="(B|C)">.*</tr> Now The second tr class will repeat an unknown number of times, with something unknown in between repetitions, but simply putting it in parentheses and added a plus doesn't work. Here's the PHP code that didn't work: $pattern = '/<tr\ class=\"A\">.*(<tr\ class=\"(B|C)\">.*<\/tr>.*)+/'; preg_match_all($pattern,$playerHtml,$scores); But it only returns the first Here's an example of something that should match: <tr class="A">blah</tr>blah <tr class="B">blah</tr>blah <tr class="B">blah</tr>blah <tr class="C">blah</tr> This only matches blahblahblah

    Read the article

  • Regular expression one or more times JAVA

    - by user1381564
    Hi i am trying to match a string against a pattern this is the possible string signal CS, NS, dl: stateType := writeOrRead0; signal CS, pS : stateType := writeOrRead0; signal dS : stateType := writeOrRead0; i am only concerned with the pattern as far as the first colon. but the number of signals define can be more than one it could be three or four even this is the regular expression i have ^signal\\s*(\\w+),*\\s*(\\w+)\\s*: it will pick up the second two signal but and for the second one it picks up CS and pS and but the d and S in the next signal when i use matcher.group() come up seperately Can anyone give me an expression that will pick up all signal names whether there is one two three or more?

    Read the article

  • @Path and regular expression (Jersey/REST)

    - by Castanho
    Hi there! I'm using Jersey in a REST project and I'm needing to use regular expression. Digging about it is simple like: @Path("/resources) public class MyResource { @GET @Path("{subResources:.*}/bar") public String get() {...} } But, I'm only capable of using regex if in my @Path contains a variable or text value, example: @Path("{SubResource1}/{subResources:.*}/bar") Or @Path("hardCodeString/{subResources:.*}/bar") Today I could run with this solution of a variable, but is not oK for my perspective. Question Does anyone have worked with something related? I'm doing something wrong? I think that this could be a bug, when working with more then one @Path, one in the Class and other in the Method. Any tips is appreciated! Regards

    Read the article

  • Need to add specific characters to regular expression

    - by lordryan
    i'm using the following regular expression to form a basic email validation. var emailRegEx = /^([a-zA-Z0-9])(([a-zA-Z0-9])*([\._\+-])*([a-zA-Z0-9]))*@(([a-zA-Z0-9\-])+(\.))+([a-zA-Z]{2,4})+$/; this works pretty well for what i need but i also need to exclude these specific characters for reasons i won't go into. !,#,$,%,^,&,*,(,),-,+,|,{,},[,],:,>,<,?,/,\,= - (the characters between the "," if that isn't clear) could someone help me with adding the second group to the first? I know the pro's and cons of using javascript to validate email addresses - i have to do it this way. thanks.

    Read the article

  • Some pro regular expressions help needed here

    - by Camran
    I need a special regular expression, have no experience in them whatsoever so I am turning to you guys on this one: I need to validate a classifieds title field so it doesn't have any special characters in it, almost. Only letters and numbers should be allowed, and also the swedish three letters å, ä, ö, and also not case sensitive. Besides the above, these should also be allowed: The "&" sign. Parenthesis sign "()" Mathematical signs "-", "+", "%", "/", "*" Dollar and Euro signs Accent sign or whatever it's called, for example in "coupé" the apostrophe above the "e". Double quote and singel quote signs. The comma "," and point "." signs Thanks

    Read the article

  • Perl regular expression question

    - by user368311
    Suppose I have variables $x1 = 'XX a b XX c d XX'; $x2 = 'XX a b XX c d XX e f XX'; I want a regular expression that will find each instance of letters between XX. I'm looking for a general solution, because I don't know how many XX's there are. I tried using /XX(.*?)XX/g but this only matches "a b" for x1 and "a b", "e f" for x2 because once the first match is found, the engine has already read the second "XX". Thanks for any help.

    Read the article

  • regular expression match does not work

    - by Carlos_Liu
    I have a string ABCD:10,20,,40;1/1;1/2,1/3,1/4 I want to split the string into the following parts: ABCD -- splited by : 10,20,,40 -- splited by ; 1/1 1/2,1/3,1/4 Why the following regular expression does not work for me ? string txt = @"ABCD:10,20,,40;1/1;1/2,1/3,1/4"; Regex reg = new Regex(@"\b(?<test>\w+):(?<com>\w+);(?<p1>\w+);(?<p2>\w+)"); Match match = reg.Match(txt);

    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

  • In linux, is it possible to do partial reads on a regular file

    - by Jimm
    I need to write an application that spits out log entries to a regular file at a very fast rate. Also, there will be another process, that can read the same file concurrently at the time, other process would be writing to it. I have following questions How does read() determine EOF, specially in the case, where the underlying file could be concurrently being modified? Is it possible for read() to return partially written data from the other process write? For example, the write process wrote half a line and read would pick that half line and return? The application would be written in C on linux 2.6.x using Ex4 filesystem UPDATE: Below link points to the patch, that locks inode in EXT4, before reading and writing. http://patchwork.ozlabs.org/patch/91834/

    Read the article

  • Perform regular expression on a PERL PDL variable

    - by Ahdee
    is it possible to perform a regular expression on a n-dimension PDL variable? For example I can add 100 to all the element by doing $a1 = pdl [1,2]; print $a1+100; However what if my array was a bunch of string that I would like to perform some task on, for example this fails. $a = pdl ['suze','david']; $a =~ s/suze/female/; print $a; not sure if this is even possible but thanks in advance. Ahdee

    Read the article

  • match word '90%' using regular expression

    - by amadhu
    Hi All, I want word '90%' to be matched with my String "I have 90% shares of this company". how can I write regular expression for same? I tried something like this: Pattern p = Pattern.compile("\\b90\\%\\b", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); Matcher m = p.matcher("I have 90% shares of this company"); while (m.find()){ System.out.println(m.group()); } but no luck. Can any one thow some lights on this? Many thanks, Archi

    Read the article

  • Schliemann's method of programming language learning

    - by DVK
    Background: 19th-century German archeologist Heinrich Schliemann was of course famous for his successful quest to find and excavate the city of Troy (an actual archeological site for the Troy of Homer's Iliad). However, he is just as famous for being an astonishing learner of languages - within the space of two years, he taught himself fluent Dutch, English, French, Spanish, Italian and Portuguese, and later went on to learn seven more, including both modern and ancient Greek. One of the methods he famously used was comparison of a known text, e.g. take a book in a language one is fluent in, take a good translation of a book in a language you wish to learn, and go over them in parallel. (various sources cited the book used by Schliemann to be the Bible, or, as the link above states, a novel). Now, for the actual question. Has anyone used (or heard of) an equivalent of Schliemann's method for learning a new programming language? E.g. instead of basing the leaning on references and tutorials, take a somewhat comprehensive set of programs known to have high-quality code in both languages implementing similar/identical algorithms and learn by comparing them? I'm curious about either personal experiences of applying such an approach, or references to something published, or existance of codebases which could be used for such an approach? What got me thinking about the idea was Project Euler and some code snippets I saw on SO, in C++, Perl and Lisp.

    Read the article

  • Yii: Multi-language website - best practices.

    - by michal
    Hi, I find Yii great framework, and the example website created with yiic shell is a good point to start... however it doesn't cover the topic of multi-language websites, unfortunately. The docs covers the topic of translating short messages, but not keeping the multi-lingual content ... I'm about to start working on a website which needs to be in at least two languages, and I'm wondering what is the best way to keep content for that ... The problem is that the content is mixed extensively with common elements (like embedded video files). I need to avoid duplicating those commons ... so far I used to have an array of arrays containing texts (usually no more than 1-2 short paragraphs), then the view file was just rendering the text from an array. Now I'd like to avoid keeping it in arrays (which requires some attention when putting double quotations " " and is inconvenient in general...). So, what is the best way to keep those short paragraphs? Should I keep them in DB like (id | msg_id | language | content ) and then select them by msg_id & language? That still requires me to create some msg_id's and embed them into view file ... Is there any recommended paradigm for which Yii has some solutions? Thanks, m.

    Read the article

  • Full Text Search MSSQL2008 show wrong display_item for Thai Language

    - by ensecoz
    I am working on MSSQL2008. My task is to investigate the issue that why FTS cannot find the right result for Thai. First, I am having the table which enable the FTS on the column 'ItemName' which is nvarchar. The Catalog is created with the Thai Language. Note that, Thai language is one of the language that doesn't separate the word by space so '????' '???' '????' are written like this in the sentence '???????????' In the table, there are many rows that include the word (????) for examples row#1 (ItemName: '???????????') On the webpage, I try to search for '????' but SQLServer cannot find it. So I try to investigate it by trying the following query in SQLServer select * from sys.dm_fts_parser(N'"???????????"', 1054, 0, 0) To see how the words are broken. The first one is the text to be break. The second parameter is specify that using Thai (WorkBreaker, so on). and here is the result: row#1 (display_item: '????', source_item: '???????????') row#2 (display_item: '????', source_item: '???????????') row#3 (display_item: '??', source_item: '???????????') Notice that the first and second row display the worng display_item '?' in the '????' isn't even Thai characters. '?' in '????' is not Thai charater either. So the question is where is those alien characters come from? I guess this i why I cannot search for '????' because the word breaker is mis-borken and keeping the wrong character in the indexes. Please help!

    Read the article

< Previous Page | 66 67 68 69 70 71 72 73 74 75 76 77  | Next Page >