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
3
votes
2 answers

Regex: Difference betwen negative lookbehind and negation

From regular-expressions.info: \b\w+(?
Benjamin Crouzier
  • 40,265
  • 44
  • 171
  • 236
3
votes
1 answer

Regex pattern to match all, and return null when specific words are found

I have this Regex expression. ^BRN.*?(?:paid|to)\s([A-Za-z\s]+)\b(?
rick458
  • 97
  • 6
3
votes
2 answers

Regex match character with negative lookbehind of two chars

I want to split a string using the character "/", but the split should only occur if there is no "\" in front of it. String: /10/102-\/ABC083.013/11/201201/20/83/30/463098194/32/7.7/40/0:20 Regex: \/*(?
Maisen1886
  • 110
  • 1
  • 10
3
votes
5 answers

Could you explain why this regex is not working?

>>> d = "Batman,Superman" >>> m = re.search("(?>> m.group(0) 'Batman' Why isn't group(0) matching Superman? This lookaround tutorial says: (?
Geo
  • 93,257
  • 117
  • 344
  • 520
3
votes
1 answer

Regex lookahead logical 'OR' - to exclude certain patterns

I've seen a lot of examples of password validation that do a logical AND. For example, password must have AT LEAST one digit (AND) AT LEAST one character (AND) length between 6 and 15 This can be written with regex 'positive…
joedotnot
  • 4,810
  • 8
  • 59
  • 91
3
votes
2 answers

Regex: remove scheme unless it's http(s). (capture negative lookbehind pattern)

I'm having a regex blackout here. How do I capture a negative lookbehind pattern again? I'm trying to remove the scheme (including ://) of a uri unless it is http/https. I'm half way there (or I thought I was, the pattern below doesn't even…
Decent Dabbler
  • 22,532
  • 8
  • 74
  • 106
3
votes
3 answers

What is lookbehind support in JS? How to replace it?

I have a string and I want to replace every 'i' that is NOT following/followed by any other i and replace it with 'z`. I know that there is negative lookahead and lookbehind. Results shoud be: i => z iki => zkz iiki => iikz ii => ii iii => iii I…
SkillGG
  • 647
  • 4
  • 18
3
votes
1 answer

negative lookahead Regexp doesnt work in ES dsl query

The mapping of my Elastic search looks like below: { "settings": { "index": { "number_of_shards": "5", "number_of_replicas": "1" } }, "mappings": { "node": { "properties": { "field1": { "type":…
3
votes
1 answer

regex does not work in swift

I am using a regular expression to find all \n occurrences in a string. The regular expression itself is working: The expression finds \n but not \\n. Which is, what I want. However, when I want to implement this in Swift for an iOS-application I…
WalterBeiter
  • 2,021
  • 3
  • 23
  • 48
3
votes
3 answers

Negative lookbehind regex (PERL) with variable characters in-between

I'm having a problem with a negative lookbehind regex. I've read the stackoverflow results and I'm afraid I don't quite understand them. I operate a game server, and I have a tool that reads the users' chat and kicks a user if they use a banned…
RustyRegex
  • 31
  • 1
3
votes
1 answer

Javascript Regex; find 'x', but not if preceded by 'y'

Something like the word 'pie' not preceded by the word 'pizza'. I'm fairly new to regexes, and this problem has been causing me trouble. If you could provide an answer using JavaScript regex syntax, i'd be that much more thankful. Edit: I could…
Maurdekye
  • 3,597
  • 5
  • 26
  • 43
3
votes
1 answer

Stop matching when meeting a sequence of chars: fixing a lookbehind

I have the following regexp: (?P.+(?
Clément
  • 12,299
  • 15
  • 75
  • 115
3
votes
3 answers

Regex negative look-behind in hgignore file

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…
jco
  • 1,335
  • 3
  • 17
  • 29
3
votes
5 answers

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

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=\"([^"]*)(?
grovel
  • 33
  • 1
  • 3
3
votes
3 answers

Why doesn't JavaScript have lookbehinds?

I know there are various work-arounds but it seems strange that a pretty common/helpful regular expression feature isn't available in JavaScript. Is there any reason for this (performance issues, implementation issues, etc.) or was it not added in…
EpicDavi
  • 6,732
  • 3
  • 19
  • 20
1 2
3
13 14