Is there a way to determine how many capture groups there are in a given regular expression?
I would like to be able to do the follwing:
def groups(regexp, s):
...
|
I have a Python regular expression that contains a group which can occur zero or many times - but when I retrieve the list of groups afterwards, only the last one ... |
When using re.sub, how to you handle a situation where you need a capture followed by a number in the replacement string? For example, you cannot use "\10" for ... |
While using regex to help solve a problem in the Python Challenge, I came across some behaviour that confused me.
from here:
(...) Matches whatever regular expression is inside ... |
Assume the following strings:
A01B100
A01.B100
A01
A01............................B100 ( whatever between A and B )
The thing is, the numbers should be \d+, and in all of the strings A will always be present, while B ... |
In my snippet below, the non-capturing group "(?:aaa)" should be ignored in matching result,
so the result should be "_bbb" only.
However, I get "aaa_bbb" in matching result; only when I specify group(2) ... |
My text is of the form:
<Story>
<Sentence id="1"> some text </Sentence>
<Sentence id="2"> some text </Sentence>
<Sentence id="3"> some text </Sentence>
My task ... |
|
I was trying to get all quoted (" or ') substrings from a string excluding the quotation marks.
I came up with this:
"((?:').*[^'](?:'))|((?:\").*[^\"](?:\"))"
For some reason the matching string still contains the quotation ... |
While going through one of the problems in Python Challenge, I am trying to solve it as follows:
Read the input in a text file with characters as follows:
DQheAbsaMLjTmAOKmNsLziVMenFxQdATQIjItwtyCHyeMwQTNxbbLXWZnGmDqHhXnLHfEyvzxMhSXzd
BEBaxeaPgQPttvqRvxHPEOUtIsttPDeeuGFgmDkKQcEYjuSuiGROGfYpzkQgvcCDBKrcYwHFlvPzDMEk
MyuPxvGtgSvWgrybKOnbEGhqHUXHhnyjFwSfTfaiWtAOMBZEScsOSumwPssjCPlLbLsPIGffDLpZzMKz
jarrjufhgxdrzywWosrblPRasvRUpZLaUbtDHGZQtvZOvHeVSTBHpitDllUljVvWrwvhpnVzeWVYhMPs
kMVcdeHzFZxTWocGvaKhhcnozRSbWsIEhpeNfJaRjLwWCvKfTLhuVsJczIYFPCyrOJxOPkXhVuCqCUgE
luwLBCmqPwDvUPuBRrJZhfEXHXSBvljqJVVfEGRUWRSHPeKUJCpMpIsrV.......
What I ... |
I have been experimenting with python re, trying to capture specific variables between specific functions. To illustrate let me give an example of file contents of a php file :-
public function ...
|
Quick regular expression question.
I'm trying to capture multiple instances of a capture group in python (don't think it's python specific), but the subsequent captures seems to overwrite the previous.
In ... |
I want to know how capturing groups (or non capturing) are affecting lookarounds in Regex.
Here are 2 example:
test (?:(?!<start).)+
test (?!<start).+
I would appreciate if anybody can explain how regex engine is interpreting ... |
Here is how I reproduce the problem:
Create a log file called 'temp.log' and paste this line into it
DEBUG: packetReceived '\x61\x62\x63'
I want to have a script which will read the line from ... |
using python3's regex capabilities, is it possible to capture variable numbers of capture blocks, based on the number of the repetitions found? for instance, in the following search strings, i ... |
I've got a function spitting out "Washington D.C., DC, USA" as output. I need to capture "Washington, DC" for reasons that have to do with how I handle every single other ... |
I am trying to find functionality in python similar to the Ruby function scan. My goal is to grab all the text in-between two curly braces in a list. If there ... |
I have some text like this:
ABCPQR01 is not at all good
EFHSTU39 is somewhat nicer
and I want to capture the ABC... and EFH... type words. The first set of three letters can ... |
I'm trying to write a regex in python to parse a Newick tree, but for the life of me I can't get the last part of it to match. There are ... |
Very beginner question about capturing groups (sorry) but hard to find the answer using Google, or figure out alone from regex websites.
I want to take the string 0.71331, 52.25378 and ... |
|
|
|