Search Results

Search found 1271 results on 51 pages for 'negative lookbehind'.

Page 1/51 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Need variable width negative lookbehind replacement

    - by Technoh
    I have looked at many questions here (and many more websites) and some provided hints but none gave me a definitive answer. I know regular expressions but I am far from being a guru. This particular question deals with regex in PHP. I need to locate words in a text that are not surrounded by a hyperlink of a given class. For example, I might have This <a href="blabblah" class="no_check">elephant</a> is green and this elephant is blue while this <a href="blahblah">elephant</a> is red. I would need to match against the second and third elephants but not the first (identified by test class "no_check"). Note that there could more attributes than just href and class within hyperlinks. I came up with ((?<!<a .*class="no_check".*>)\belephant\b) which works beautifully in regex test software but not in PHP. Any help is greatly appreciated. If you cannot provide a regular expression but can find some sort of PHP code logic that would circumvent the need for it, I would be equally grateful.

    Read the article

  • Remove leading whitespaces using variable length lookbehind in RegExp

    - by Shizhidi
    Hello, I'm wondering if variable length lookbehind assertions are supported in JavaScript's RegExp engine? For example, I'm trying to match the string "variable length" in the string "[a lot of whitespaces and/or tabs]variable length lookbehind", and I have something like this but it does not go well in various RegExp testers: ^(?<=[ \t]+).+(?= lookbehind) If it's an illegal pattern, what would be a good workaround to it? Thanks!

    Read the article

  • grep with negative lookbehind

    - by Dan Fabulich
    I'm trying to grep through a bunch of files in nested subdirectories to look for regular expression matches; my regex requires negative lookbehind. Perl has negative lookbehind, but as far as I can tell GNU grep doesn't support negative lookbehinds. What's the easiest way to get an equivalent to GNU grep that supports negative lookbehinds? (I guess I could write my own mini-grep in Perl, but that doesn't seem like it should be necessary. My copy of the Perl Cookbook includes source for tcgrep; is that what I should use? If so, where's the latest version? Don't tell me I have to type this entire program!)

    Read the article

  • Backreferences in lookbehind

    - by polygenelubricants
    Can you use backreferences in a lookbehind? Let's say I want to split wherever behind me a character is repeated twice. String REGEX1 = "(?<=(.)\\1)"; // DOESN'T WORK! String REGEX2 = "(?<=(?=(.)\\1)..)"; // WORKS! System.out.println(java.util.Arrays.toString( "Bazooka killed the poor aardvark (yummy!)" .split(REGEX2) )); // prints "[Bazoo, ka kill, ed the poo, r aa, rdvark (yumm, y!)]" Using REGEX2 (where the backreference is in a lookahead nested inside a lookbehind) works, but REGEX1 gives this error at run-time: Look-behind group does not have an obvious maximum length near index 8 (?<=(.)\1) ^ This sort of make sense, I suppose, because in general the backreference can capture a string of any length (if the regex compiler is a bit smarter, though, it could determine that \1 is (.) in this case, and therefore has a finite length). So is there a way to use a backreference in a lookbehind? And if there isn't, can you always work around it using this nested lookahead? Are there other commonly-used techniques?

    Read the article

  • How to non-greedy multiple lookbehind matches

    - by ArtK
    Source: <prefix><content1><suffix1><prefix><content2><suffix2> Engine: PCRE RegEx1: (?<=<prefix>)(.*)(?=<suffix1>) RegEx2: (?<=<prefix>)(.*)(?=<suffix2>) Result1: <content1> Result2: <content1><suffix1><prefix><content2> The desired result for RegEx2 is just <content2> but it is obviously greedy. How do I make RegEx2 non-greedy and use only the last matching lookbehind? [I hope I have translated this correctly from the NoteTab syntax. I don't do much RegEx coding. The <prefix>, <content> & <suffix> terms are just meant to represent arbitrary strings. Only the "<" in the "?<=" lookbehind command is significant.] I suspect it is something simple but after too many hours of searching I'm giving up on solving it myself. Thanks for the help Art

    Read the article

  • RegEx Advanced : Positive lookbehind

    - by mpneuried
    This is my test-string: <img rel="{objectid:498,newobject:1,fileid:338}" width="80" height="60" align="left" src="../../../../files/jpg1/Desert1.jpg" alt="" /> I want to get each of the JSON formed Elements inbetween the rel attribute. It's working for the first element (objectid). Here is my ReqEx, which works fine: (?<=(rel="\{objectid:))\d+(?=[,|\}]) But i want to do somthing like this, which doesn't work: (?<=(rel="\{.*objectid:))\d+(?=[,|\}]) So i can parse every element of the search string. I'm using Java-ReqEx

    Read the article

  • OCaml: Matching with any negative

    - by nicotine
    Is there a way to get pattern matching to match my value with any negative number? It does not matter what the negative number is I just need to match with any negative. I have accomplished what I want with this simple code: let y = if(n < 0) then 0 else n in match y with 0 -> [] | _ -> [x] @ clone x (n - 1) But I want to eliminate that if statement and just get it to check it as another case in the match statement

    Read the article

  • FileInputStream negative skip

    - by Peter Štibraný
    I'm trying to find more about history of FileInputStream.skip(negative) operation. According to InputStream documentation: If n is negative, no bytes are skipped. It seems that implementation of FileInputStream from Sun used to throw IOException instead, which is now also documented in Javadoc: If n is negative, an IOException is thrown, even though the skip method of the InputStream superclass does nothing in this case. I just tried that, and found that FileInputStream.skip(-10) did in fact return -10! It didn't threw exception, it didn't even return 0, it returned -10. (I've tried with Java 1.5.0_22 from Sun, and Java 1.6.0_18 from Sun). Is this a known bug? Why hasn't it been fixed, or why documentation is kept the way it is? Can someone point me to some discussion about this issue? I can't find anything.

    Read the article

  • Regex negative look-behind in hgignore file

    - by jco
    I'm looking for a way to modify my .hgignore file to ignore all "Properties/AssemblyInfo.cs" files except those in either the "Test/" or the "Tests/" subfolders. I tried using the negative look-behind expression (?<!Test)/Properties/AssemblyInfo\.cs$, but I didn't find a way to "un-ignore" in both folders "Test/" and "Tests/".

    Read the article

  • Function Returning Negative Value

    - by Geowil
    I still have not run it through enough tests however for some reason, using certain non-negative values, this function will sometimes pass back a negative value. I have done a lot of manual testing in calculator with different values but I have yet to have it display this same behavior. I was wondering if someone would take a look at see if I am missing something. float calcPop(int popRand1, int popRand2, int popRand3, float pERand, float pSRand) { return ((((((23000 * popRand1) * popRand2) * pERand) * pSRand) * popRand3) / 8); } The variables are all contain randomly generated values: popRand1: between 1 and 30 popRand2: between 10 and 30 popRand3: between 50 and 100 pSRand: between 1 and 1000 pERand: between 1.0f and 5500.0f which is then multiplied by 0.001f before being passed to the function above Edit: Alright so after following the execution a bit more closely it is not the fault of this function directly. It produces an infinitely positive float which then flips negative when I use this code later on: pPMax = (int)pPStore; pPStore is a float that holds popCalc's return. So the question now is, how do I stop the formula from doing this? Testing even with very high values in Calculator has never displayed this behavior. Is there something in how the compiler processes the order of operations that is causing this or are my values simply just going too high? If the later I could just increase the division to 16 I think.

    Read the article

  • PHP profiling with microtime(): Negative time?

    - by Boldewyn
    For a very simple profiling I use microtime() like this: $now = microtime(); for (...) { // do something echo microtime() - $now; $now = microtime(); } Now, the output of the echo line seems completely random, that is, I expected fluctuations, but I don't expected negative numbers showing up. However, a typical result contains ~ 1/3 negative numbers. I confirmed this on Solaris (PHP 5.0.x) and WinVista (PHP 5.2.3). What the heck is going on here? Have I invented accidently a time machine?

    Read the article

  • How to read in a negative double with scanf() in C

    - by rize
    I'm learning basics of C and writing a simple first order equation solver. I want the input to be exactly ax+b=c or ax-b=c, where a, b, c are double type. I'm employing scanf() to read in user input and to check if it's of the correct form. However, if I enter a negative double, -4.6 say, as the "a" in the equation, scanf() won't read the a,b,c correctly. I'm using %lf inside scanf(). How do I read a negative double, then? Many thanks. My code: if (scanf("%lfx+%lf=%lf", &a, &b, &c)) more code If I use as the input "-6.2x+3.4=-5.9", the value 3.4 will be assinged to variable a, while b and c remain as they were and "more code" is run.

    Read the article

  • Perl: Negative look behind regex question [migrated]

    - by James
    The Perlre in Perldoc didn't go into much detail on negative look around but I tried testing it, and didn't work as expected. I want to see if I can differentiate a C preprocessor macro definition (e.g. #define MAX(X) ....) from actual usage (y = MAX(x);), but it didn't work as expected. my $macroName = 'MAX'; my $macroCall = "y = MAX(X);"; my $macroDef = "# define MAX(X)"; my $boundary = qr{\b$macroName\b}; my $bstr = " MAX(X)"; if($bstr =~ /$boundary/) { print "boundary: $bstr matches: $boundary\n"; } else { print "Error: no match: boundary: $bstr, $boundary\n"; } my $negLookBehind = qr{(?<!define)\b$macroName\b}; if($macroCall =~ /$negLookBehind/) # "y = MAX(X)" matches "(?<!define)\bMAX\b" { print "negative look behind: $macroCall matches: $negLookBehind\n"; } else { print "no match: negative look behind: $macroCall, $negLookBehind\n"; } if($macroDef =~ /$negLookBehind/) # "#define MAX(X)" should not match "(?<!define)\bMAX\b" { print "Error: negative look behind: $macroDef matches: $negLookBehind\n"; } else { print "no match: negative look behind: $macroDef, $negLookBehind\n"; } It seems that both $macroDef and $macroCall seem to match regex /(?<!define)\b$macroName\b/. I backed off from the original /(?<\#)\s*(?<!define)\b$macroName\b/ since that didn't work either. So what did I screw up? Also does Perl allow chaining of multiple look around expressions?

    Read the article

  • RegExp: want to find all links that do not end in ".html"

    - by grovel
    Hi, I'm a relative novice to regular expressions (although I've used them many times successfully). I want to find all links in a document that do not end in ".html" The regular expression I came up with is: href=\"([^"]*)(?<!html)\" In Notepad++, my editor, href=\"([^"]*)\" finds all the links (both those that end in "html" and those that do not). Why doesn't negative lookbehind work? I've also tried lookahead: href=\"[^"]*(?!html\") but that didn't work either. Can anybody help? Cheers, grovel

    Read the article

  • Why does multiplying a double by -1 not give the negative of the current answer

    - by Ankur
    I am trying to multiply a double value by -1 to get the negative value. It continues to give me a positive value double man = Double.parseDouble(mantissa); double exp; if(sign.equals("plus")){ exp = Double.parseDouble(exponent); } else { exp = Double.parseDouble(exponent); exp = exp*-1; } System.out.println(man+" - "+sign+" - "+exp); The printed result is 13.93 - minus - 2.0 which is correct except that 2.0 should be -2.0

    Read the article

  • strange behavior in vim with negative look-behind

    - by João Portela
    So, I am doing this search in vim: /\(\(unum\)\|\(player\)=\)\@<!\"1\" and as expected it does not match lines that have: player="1" but matches lines that have: unum="1" what am i doing wrong? isn't the atom to be negated all of this: \(\(unum\)\|\(player\)=\) naturally just doing: /\(\(unum\)\|\(player\)=\) matches unum= or player=.

    Read the article

  • Negative numbers, arrays javascript!

    - by zizzamia
    I was implementing a routing algorithm in javascript, but when I assign a negative one variable in the array gives me this error: invalid array length. var node = new Array() node[0] = new Array(6,7) node[1] = new Array(5,-4,8) node[2] = new Array(-2) //Here, invalid array length I do not know how to resolve this error.

    Read the article

  • CSS Negative margins for positioning.

    - by Kyle Sevenoaks
    Is it ok to use negative margins for positioning? I have a lot in my current site and feel like it's not such a stable way to position things. I usually suggest to use them too. For example I have a checkout page with three divs on top of each other <div class="A"> header </div> <div class="B"> content </div> <div class="C"> footer </div> (A, B and C), which are meant to sit on top of each other, to appear attached. I did this using: .B { margin-top: -20px; } On div B, to meet the bottom of div A. Is this good practice or shall I re-code using top and left?

    Read the article

  • C# regex: negative lookahead fails with the single line option

    - by Sylverdrag
    I am trying to figure out why a regex with negative look ahead fails when the "single line" option is turned on. Example (simplified): <source>Test 1</source> <source>Test 2</source> <target>Result 2</target> <source>Test 3</source> This: <source>(?!.*<source>)(.*?)</source>(?!\s*<target) will fail if the single line option is on, and will work if the single line option is off. For instance, this works (disables the single line option): (?-s:<source>(?!.*<source>)(.*?)</source>(?!\s*<target)) My understanding is that the single line mode simply allows the dot "." to match new lines, and I don't see why it would affect the expression above. Can anyone explain what I am missing here?

    Read the article

  • Using the mpz_powm functions from the GMP/MPIR libraries with negative exponents

    - by Mihai Todor
    Please consider the following code: mpz_t x, n, out; mpz_init_set_ui(x, 2UL); mpz_init_set_ui(n, 7UL); mpz_init(out); mpz_invert(out, x, n); gmp_printf ("%Zd\n", out);//prints 4. 2 * 4 (mod 7) = 1. OK mpz_powm_ui(out, x, -1UL, n);//prints 1. 2 * 1 (mod 7) = 2. How come? gmp_printf ("%Zd\n", out); mpz_clear(x); mpz_clear(n); mpz_clear(out); I am unable to understand how the mpz_powm functions handle negative exponents, although, according to the documentation, it is supposed to support them. I would expect that raising a number to -1 modulo n is equivalent to inverting it modulo n. What am I missing here?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >