Questions tagged [negative-lookbehind]

In regular expressions, negative lookbehind checks if the character before the current character does NOT match a certain character.

In regular expressions, negative lookbehind checks if the character before the current character does NOT match a certain character. For example, (?<!a)b matches a "b" that is not preceded by an "a", using the negative lookbehind.

207 questions
-1
votes
0 answers

PHP PCRE regex negative lookbehind not working as expected

Edit: None of the supplied links attempt to answer the question of negative lookbehinds not behaving as I would expect, given documentation I've read: https://www.regular-expressions.info/lookaround.html, https://regexr.com/,…
psyjoniz
  • 80
  • 1
  • 7
-1
votes
1 answer

php check ncr with negative lookbehind and greedy doesn't work

I want to find a erroneous NCR without &# and remedy it, the unicode is 4 or 5 decimal digit, I write this PHP statement: function repl0($m) { return '&#'.$m[0]; } $s = "This is a good 23200; sample ship"; echo "input1=…
Scott Chu
  • 972
  • 14
  • 26
-1
votes
1 answer

matching all 5 digits numbers other than 3 specific ones-without negative lookbehind

So I am trying to match with any 5 digits number other than 10000,11000,68000. With negative lookbehind, lookaround etc. this code does exactly what I want ^[0-9]{5}(?
gülsemin
  • 25
  • 4
-1
votes
2 answers

Negative Lookbehind not negating entire match

EDIT: To be more precise the hostnames could come anywhere within a paragraph, I want to completely discard any hosts that start with https:// (or http:// actually, but just testing with https://), I don't want to capture their hostnames, but I do…
user2110291
  • 141
  • 1
  • 8
-1
votes
1 answer

Regex replace if matching group not preceded by `\` exept if preceded by `\\`

My Goal What I want to do is something similar to this: let json_obj = { hello: { to: 'world' }, last_name: { john: 'smith' }, example: 'a ${type}', // ${type} -> json_obj.type type: 'test' } //…
Elie G.
  • 1,514
  • 1
  • 22
  • 38
-1
votes
1 answer

Regex for finding a phrase that isn't already updated

I'm looking for some assistance with Regex. I have a project in which I'm writing a VBA macro to update hundreds of thousands of documents by find/replacing a phrase. The Phrase is "Company Name" and needs to be "Company Name LLP". The issue is that…
JBHorne
  • 11
  • 1
-1
votes
1 answer

Negative lookahead to parse HTML

I've got a pattern like that: /]*?)(?!\sdata-src=([\'\"])[\S\h\v]*?\2)\ssrc=([\'\"])([\S\h\v]*?)\3/igm And that's what I want to achieve: # this should be matched, and it is # this one…
roomcayz
  • 2,334
  • 4
  • 17
  • 26
-1
votes
3 answers

Unifying lookahead and lookbehind into a single regex operator

I am making a simplified/sugary wrapper for regex which cuts out many of the more complicated regex functions (whilst still keeping the essentials for 99% of uses), and which also tries to tidy up the syntax a little. In regards to negative…
Dan W
  • 3,520
  • 7
  • 42
  • 69
-1
votes
4 answers

Negative lookahead to match server directories not properly working

Given the following 3 example paths representing server paths i am trying to create a skiplist for my FTP client via PCRE regular expressions but can't seem to get the wished…
user1014412
  • 359
  • 1
  • 2
  • 15
-1
votes
3 answers

negative lookbehind stopping at quantified whitespace?

I need to insert

tags to surround each list element in a HTML fragment. This must not create nested paragraphs, which is why i want to use lookahead/lookbehind assertions to detect if the content is already enclosed in a paragraph tag. So far,…

Kaii
  • 20,122
  • 3
  • 38
  • 60
-2
votes
1 answer

How would I rewrite PCRE regular expressions so that they're compatible with JavaScript?

As part of a security related project written in Node.js, I'm looking at some of the work done by the team behind PHPIDS, specifically their filter list, which is composed of a large amount of regular expressions that matches a variety of different…
-2
votes
1 answer

Equivalent regex in Javascript

I am trying to validate AWS accessKey and secretKey. Found an AWS blog post which suggest a regex to validate accessKey and secretKey https://blogs.aws.amazon.com/security/post/Tx1XG3FX6VMU6O5/A-safer-way-to-distribute-AWS-credentials-to-EC2 But the…
ruman hassan
  • 59
  • 2
  • 9
1 2 3
13
14