Questions tagged [positive-lookbehind]
12 questions
2
votes
2 answers
python regex positive look behind with optional character
I am trying to come up with a regex that captures the word zone in both scenarios below:
txt1='cast("zone" as varchar(100)) as zoneID'
txt2='cast(zone as varchar(100)) as zoneID'
As you can see, the " is optional. sometimes it appears and sometimes…

chulo
- 53
- 8
2
votes
2 answers
How to select a word which contains a previous word?
I'm trying to select a word that is on the second line, but first I need to check if there is a word on the first line, regex example:
(?<=isaac)select
this is the text
abcdefgisaachijklmnopqrstuvwxyz
abcdefgselecthijklmno
Just to clarify my idea…

megaultron
- 399
- 2
- 15
1
vote
2 answers
Replace every symbol of the word after delimiter using python re
I would like to replace every symbol of a word after - with *.
For example:
asd-wqe ffvrf => asd-*** ffvrf
In TS regex it could be done with (?<=-\w*)\w and replacement *. But default python regex engine requires lookbehinds of fixed…

markalex
- 8,623
- 2
- 7
- 32
1
vote
2 answers
Regex: Only the first match of word after a given word is returned
I have a test string
"apple search from here apple, banana, apple."
and the following RegEx
(?i)(?<=search from here\s)(\bapple|banana|orange\b)(\s+(\bapple|banana|orange\b))*
I'm getting a match only for the first occurrence of apple. See…

bigb055
- 198
- 3
- 14
1
vote
1 answer
Alternative to positive lookbehind regex
I am working with Prism.js for syntax highlighting and I have a regex for detecting Kotlin infix function (?<=\w\s)(\w+)(?=\s\w) (https://regex101.com/r/wVSO6G/1) which uses a positive look ahead and a positive look behind, however this does not…

User12322341232142
- 93
- 1
- 8
1
vote
1 answer
JS regexp positive lookbehind no match
Here's the string and the sentence I want to match (extract).
let pigs = "\X The animal 0000 I really dig \X Above all others is the pig. 222 \X Pigs are noble. Pigs are clever 3333, \X Pigs are 5555 courteous.\X However, Now and then, to break this…

Lukasz Pospiech
- 15
- 5
1
vote
2 answers
Using regex to create a list of dictionaries with positive lookbehind
I am trying to create a list of dictionaries using regex positive lookbehind. I tried two different codes:
Variation 1
string = '146.204.224.152 - lubo233'
for item in re.finditer( "(?P[0-9]*[.][0-9]*[.][0-9]*[.][0-9]*)(?P(?<= -…

Kane Chew
- 3,693
- 4
- 12
- 24
0
votes
1 answer
Using a backreference to a group captured in positive lookbehind and inserting the group in a positive lookforward in regex?
I would like to match a text that is surrounded by one of two allowed symbols (let's say & and #). Whichever of the two symbols is used before the text, should follow after the text; the second symbol option is not allowed (eg. &Time& and #Time# are…

Polishko
- 1
- 1
0
votes
0 answers
Is there any alternate for Positive lookbehind regex for safari browser?
this regex /(?<=.+)(\n|\r|\n\r|\r\n){1,}/g works for major browser but is breaking on safari. Is there any alternate for the same?

ranjeet kumar
- 251
- 2
- 10
0
votes
0 answers
re.findall and re.finditer running positive lookbehind assertion got different result
Below is the code:
import re
a = "111234567890"
b = re.finditer(r"((?<=\d)\d{3})+", a)
print("finditer: ")
print(b)
for item in b:
print(item.group(), end='\n\n')
c = re.findall(r"((?<=\d)\d{3})+", a)
print("findall: ")
print(c,…

YYDonald
- 1
0
votes
0 answers
regEx positive lookbehind in VBA language
I want to run regEx positive lookbehind in VBA language, but it is not supported in VBA language. The process I want to run is (?<=src="")[\w-.]+(?=/)?
How can I alternatively write (?<=src="") here?
Sample: https://regexr.com/65cmi

Enes ALTUN
- 26
- 5
0
votes
2 answers
Why is PCRE grep treating forward slashes as whitespace?
On bash, I'm trying to get the uppercase letter immediately after a whitespace (A from File A.jpg).
echo "Path/To/File A.jpg" | grep -oP '[A-Z](?!/s)'
This is a negative lookahead (?! that should return any uppercase after a whitespace. So, it…

Rodrigo
- 4,706
- 6
- 51
- 94