lookbehind Questions

5

Solved

There are some features in modern regex engines which allow you to match languages that couldn't be matched without that feature. For example the following regex using back references matches the l...
Advocacy asked 4/6, 2010 at 12:44

3

Solved

I created a test using grep but it does not work in sed. grep -P '(?<=foo)bar' file.txt This works correctly by returning bar. sed 's/(?<=foo)bar/test/g' file.txt I was expecting footes...
Imprint asked 29/9, 2014 at 23:2

3

Solved

I want to match a string which may contain a type of character before the match, or the match may begin at the beginning of the string (same for end of string). For a minimal example, consider the...
Ingaborg asked 28/4, 2015 at 3:8

3

Solved

I am trying to handle un-matched double quotes within a string in the CSV format. To be precise, "It "does "not "make "sense", Well, "Does "it" should ...
Addy asked 20/11, 2013 at 7:31

4

Solved

I've almost got the answer here, but I'm missing something and I hope someone here can help me out. I need a regular expression that will match all but the first letter in each word in a sentence....
Chausses asked 25/1, 2011 at 5:40

7

Solved

For example, in this text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eu tellus vel nunc pretium lacinia. Proin sed lorem. Cras sed ipsum. Nunc a libero quis risus sollicitudi...
Preventive asked 13/2, 2009 at 14:52

3

Solved

Very simple problem. I just need to capture some strings using a regex positive lookbehind, but I don't see a way to do it. Here's an example, suppose I have some strings: library(stringr) myStri...
Pearle asked 4/3, 2016 at 19:21

1

Solved

How can I use capturing groups inside lookbehind assertions? I tried to use the same formula as in this answer. But that does not seem to work with lookbehinds. Conceptually, this is what I was try...
Pastose asked 24/12, 2020 at 11:19

3

Solved

I'm doing a simple Lookbehind Assertion to get a segment of the URL (example below) but instead of getting the match I get the following error: Uncaught SyntaxError: Invalid regular expression: /(...
Sample asked 12/5, 2011 at 5:31

3

Solved

I got the following scenarios: 1) car on the right shoulder 2) car on the left shoulder 3) car on the shoulder I want to match "shoulder" when left|right is not present. So only 3) return "shoul...
Biblioclast asked 28/7, 2014 at 1:34

2

Solved

Given this vector: ba <- c('baa','aba','abba','abbba','aaba','aabba')' I want to change the final a of each word to i except baa and aba. I wrote the following line ... gsub('(?<=a[ab]b...
Bevus asked 27/3, 2015 at 19:4

2

I am having trouble getting this regex to work and none of the canned ones I have found work reliably. The desired result: Produce the following via regex matches: "Person One" "Person Two" "Per...
Freon asked 11/5, 2018 at 0:10

2

Solved

I need to match the string "foo" from a string with this format: string = "/foo/boo/poo" I tied this code: poo = "poo" foo = re.match('.*(?=/' + re.escape(poo) + ')', string).group(0) and it ...
Groce asked 19/12, 2017 at 12:14

5

Solved

For example,the regex below will cause failure reporting lookbehind assertion is not fixed length: #(?<!(?:(?:src)|(?:href))=["\']?)((?:https?|ftp)://[^\s\'"<>()]+)#S Such kind ...
Jobey asked 26/9, 2010 at 2:59

1

Solved

The following python code: import re line="http://google.com" procLine = re.match(r'(?<=http).*', line) if procLine.group() == "": print(line + ": did not match regex") else: print(procLine....
Kinross asked 30/9, 2017 at 10:20

2

Solved

I use python regular expressions (re module) in my code and noticed different behaviour in theese cases: re.findall(r'\s*(?:[a-z]\))?[^.)]+', 'a) xyz. b) abc.') # non-capturing group # results in ...
Decarbonate asked 4/2, 2013 at 17:46

1

Solved

Im trying to do something fairly simple with regular expression in python... thats what i thought at least. What i want to do is matching words from a string if its preceded and followed by a whit...
Commutate asked 19/7, 2017 at 11:51

2

Solved

I'd like to use a regex to find an exact string, but not if it's part of a comment, as designated by //. So for example, in the string: hello apple apples // eat an apple It should match the ...
Offish asked 19/1, 2016 at 0:35

2

Solved

Note that this question is in the context of Julia, and therefore (to my knowledge) PCRE. Suppose that you had a string like this: "sssppaaasspaapppssss" and you wanted to match, individually, ...
Knobkerrie asked 19/7, 2015 at 15:31

3

Solved

I get this error: java.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index 22 ([a-z])(?!.*\1)(?<!\1.+)([a-z])(?!.*\2)(?<!\2.+)(.)(\3)(.)(...
Apograph asked 25/9, 2011 at 4:59

3

Solved

My question is related with lookbehinds, I want to find all the first numbers after the word "this", I have the following data: 188282 this is an example of a number 12345 and 54321 188282 this is...
Torrefy asked 8/1, 2014 at 11:20

1

Solved

I wrote this regex to match all href and src links in an HTML page; (I know I should be using a parser; this just experimenting): /((href|src)\=\").*?\"/ # Without look-behind It works fine, but ...
Mesosphere asked 13/11, 2013 at 6:56

1

Solved

Why doesn't the regex (?<=fo).* match foo (whereas (?<=f).* does)? "foo" =~ /(?<=f).*/m => 1 "foo" =~ /(?<=fo).*/m => nil This only seems to happen with singleline mode turned ...
Commutate asked 5/3, 2013 at 21:4

2

Solved

I'm trying to match some text if it does not have another block of text in its vicinity. For example, I would like to match "bar" if "foo" does not precede it. I can match "bar" if "foo" does not i...
Marisolmarissa asked 30/11, 2012 at 19:15

5

Solved

I am having problems with the nested '+'/'-' lookahead/lookbehind in regex. Let's say that I want to change the '*' in a string with '%' and let's say that '\' escapes the next character. (Turning...
Tompkins asked 23/10, 2011 at 15:45

© 2022 - 2024 — McMap. All rights reserved.