Search Results

Search found 5414 results on 217 pages for 'regular'.

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

  • JavaScript regular expression literal persists between function calls

    - by Charles Anderson
    I have this piece of code: function func1(text) { var pattern = /([\s\S]*?)(\<\?(?:attrib |if |else-if |else|end-if|search |for |end-for)[\s\S]*?\?\>)/g; var result; while (result = pattern.exec(text)) { if (some condition) { throw new Error('failed'); } ... } } This works, unless the throw statement is executed. In that case, the next time I call the function, the exec() call starts where it left off, even though I am supplying it with a new value of 'text'. I can fix it by writing var pattern = new RegExp('.....'); instead, but I don't understand why the first version is failing. How is the regular expression persisting between function calls? (This is happening in the latest versions of Firefox and Chrome.) Edit Complete test case: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <title>Test Page</title> <style type='text/css'> body { font-family: sans-serif; } #log p { margin: 0; padding: 0; } </style> <script type='text/javascript'> function func1(text, count) { var pattern = /(one|two|three|four|five|six|seven|eight)/g; log("func1"); var result; while (result = pattern.exec(text)) { log("result[0] = " + result[0] + ", pattern.index = " + pattern.index); if (--count <= 0) { throw "Error"; } } } function go() { try { func1("one two three four five six seven eight", 3); } catch (e) { } try { func1("one two three four five six seven eight", 2); } catch (e) { } try { func1("one two three four five six seven eight", 99); } catch (e) { } try { func1("one two three four five six seven eight", 2); } catch (e) { } } function log(msg) { var log = document.getElementById('log'); var p = document.createElement('p'); p.innerHTML = msg; log.appendChild(p); } </script> </head> <body><div> <input type='button' id='btnGo' value='Go' onclick='go();'> <hr> <div id='log'></div> </div></body> </html> The regular expression continues with 'four' as of the second call on FF and Chrome, not on IE7 or Opera.

    Read the article

  • Regular expression for pipe delimited and double quoted string

    - by Hiren Amin
    I have a string something like this: "2014-01-23 09:13:45|\"10002112|TR0859657|25-DEC-2013>0000000000000001\"|10002112" I would like to split by pipe apart from anything wrapped in double quotes so I have something like (similar to how csv is done): [0] => 2014-01-23 09:13:45 [1] => 10002112|TR0859657|25-DEC-2013>0000000000000001 [2] => 10002112 I would like to know if there is a regular expression that can do this?

    Read the article

  • Regular Expression for username

    - by neobie
    I need help on regular expression on the condition (4) below: Begin with a-z End with a-z0-9 allow 3 special characters like ._- The characters in (3) must be followed by alphanumeric characters, and it cannot be followed by any characters in (3) themselves. Not sure how to do this. Any help is appreciated, with the sample and some explanations.

    Read the article

  • Simple regular expression for decimal numbers?

    - by finch
    I know this may be the simplest question ever asked on Stack Overflow, but what is the regular expression for a decimal with a precision of 2? Valid examples: 123.12 2 56754 92929292929292.12 0.21 3.1 Invalid examples: 12.1232 2.23332 e666.76 Sorry for the lame question, but for the life of me I haven't been able to find anyone that can help! The decimal place may be option, and that integers may also be included.

    Read the article

  • regular expression for challenge value

    - by Salman
    Hi what will be the regular expression to extract challenge var value i am interested in this vlaue 03AHJ_Vut9LJLOJuCsjF9PbSSMncTyUe7Y4dHX11eRLae3LGfDZ0hSfDR7jZq2ZrKJxyC-LRSSppv72oHKaQMsd-EnoVNL6p7liTh7siN26zzTA_E2rcC_JQ15613Azz4qm8HjPtAyksUdc7QZydszwolk92hBPrAAig this value changes every time we refresh it so the expression has to be generic enough to pick up what ever is the value var RecaptchaState = { site : '6LeKCL8SAAAAADV5Dr-lfY2eOEV8rubeN25BAKp2', challenge : '03AHJ_Vut9LJLOJuCsjF9PbSSMncTyUe7Y4dHX11eRLae3LGfDZ0hSfDR7jZq2ZrKJxyC-LRSSppv72oHKaQMsd-EnoVNL6p7liTh7siN26zzTA_E2rcC_JQ15613Azz4qm8HjPtAyksUdc7QZydszwolk92hBPrAAig', is_incorrect : false, programming_error : '', error_message : '', server : 'http://www.google.com/recaptcha/api/', timeout : 18000}; any help will be appreciated, or any method to extract this value in any server side lang

    Read the article

  • Regular Expression Help

    - by Dave
    Looking for some help with a Regular Expression to do the following: Must be Alpha Char Must be at least 1 Char Must NOT be a specific value, e.g. != "Default" Thanks for any help, Dave

    Read the article

  • regular expression with special chars

    - by xRobot
    I need a regular expression to validate string with one or more of these characters: a-z A-Z ' àòèéùì simple white space FOR EXAMPLE these string are valide: D' argon calabrò maryòn l' Ancol these string are NOT valide: hello38239 my_house work [tab] with me I tryed this: re.match(r"^[a-zA-Z 'òàèéìù]+$", self.cleaned_data['title'].strip()) It seems to work in my python shell but in Django I get this error: SyntaxError at /home/ ("Non-ASCII character '\\xc3' ... Why ?

    Read the article

  • Regular Expression to extract HREFS

    - by James Jeffery
    I'm looking for a regular expression that can extract the href from this: <a href="/tr/blog.php?post=3593&user=930"> There are hundreds of links on the page so I need to extract only those that contain /tr/blog.php So in the end I should be left with a list of links that start in /tr/blog Thanks for any help. It's really puzzling me.

    Read the article

  • Good starting point to learn regular expressions.

    - by Jeremy Rudd
    I'm good at learning new languages and platforms, though whenever I try to learn Reg Ex I cannot make sense of it. I once even used the Regular Expression Designer to try and put some together. What's a good starting point to understanding what looks like the only rocket-science programming language in the world? Links to articles, books or anything else that could help me get my grounding would be appreciated.

    Read the article

  • Regular Expression to parse SQL Structure

    - by user351429
    I am trying to parse the MySQL data types returned by "DESCRIBE [TABLE]". It returns strings like: int(11) float varchar(200) int(11) unsigned float(6,2) I've tried to do the job using regular expressions but it's not working. PHP CODE: $string = "int(11) numeric"; $regex = '/(\w+)\s*(\w+)/'; var_dump( preg_split($regex, $string) );

    Read the article

  • php regular expression assistance bold a filename

    - by jason
    I am not very good, with regular expression in php I am trying to get a reg_expression to find all file names such as /file-name-here.php and make it bold. This expression works in Flash but not in php it also doesn't accept the '-' i'm not sure why i can't get it to work with preg_replace /(https?://)?(www\.)?([a-zA-Z0-9_%]*)\b\.[a-z]{2,4}(\.[a-z]{2})?((/[a-zA-Z0-9_%]*)+)?(\.[a-z]*)?/g

    Read the article

  • Limit number of alpha characters in regular expression

    - by beardedd
    I've been struggling to figure out how to best do this regular expression. Here are my requirements: Up to 8 characters Can only be alphanumeric Can only contain up to three alpha characters [a-z] (zero alpha characters are valid to) Any ideas would be appreciated. This is what I've got so far, but it only looks for contiguous letter characters: ^(\d|([A-Za-z])(?!([A-Za-z]{3,}))){0,8}$

    Read the article

  • Regular Expression

    - by TiagoDias
    Hi all, I cannot manage to get a working regular expression (for use in ASP.NEt Validataor) for the following criteria: - I want all chars from A-Z a-z 0-9 - I don't want the Enter key I have the expression: [\w\s,.-/]*[^\n] but that don't works. Please give-me a hint, Thanks.

    Read the article

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