All Questions
2,987 questions
-1
votes
1
answer
64
views
Split string at patterns alternatingly [closed]
I'm relatively new to regex and I'm struggeling with a very specific appliciation. Say I have a string such as this:
"> The following will be split : This was split: But this wasn't: And ...
2
votes
2
answers
85
views
Splitting string into two parts with digits occurring in both parts
I have a sample string like 3425%4368, % in the string devide it into two parts, I want to find all digitals in the first part that has occurrence in the second part.
you can see, 3 and 4 in the first ...
0
votes
2
answers
98
views
Return elements from a list that match a pattern [duplicate]
I have a list of words as below:
STR = ['aa', 'dffg', 'aa2', 'AAA3']
I want to get a list of elements from the above list that match a string:
to_match = 'aa'
I tried the code below:
import re
[re....
1
vote
2
answers
68
views
re.sub eats next charater when replacing with more [duplicate]
so i was trying to format my text for markdown v2, basically I just want to replace a special character a with \a
when trying to do this with regex, it does so< but the new symbol eats up the next ...
0
votes
1
answer
61
views
In a Python regex (re), how can I match the start of a string (^) OR a non-alphanumeric character (\W)?
I am using the Python regex package re for example to match a hashtag or url. A hashtag starts with a #, which cannot be in the middle of a word. Hence, it can be at the start of a word, which I can ...
0
votes
2
answers
81
views
How can I replace every instance of a character from 3 groups of characters with just 3 different characters respectively?
This is my input:
"Once there was a (so-called) rock. it.,was not! in fact, a big rock."
I need it to output an array that looks like this
["Once", " ", "there&...
-5
votes
1
answer
108
views
How to Separate Text and Code in Python Strings?
I've encountered an issue in python. I have a string that contains both a message and code, and I need to separate them and pass each to different functions. An example:
text = """
Can ...
0
votes
2
answers
116
views
Regular expression works with strings, but not with input from files in python
Im trying to read a key and identifier from a .txt-file with the following content:
Wiederherstellungsschlüssel für die BitLocker-Laufwerkverschlüsselung
Um zu überprüfen, ob es sich um den ...
2
votes
1
answer
94
views
Using re to match a digit + any contiguous duplicates and storing the duplicates, not just the digit as the result [duplicate]
I'm trying to use re.findall(pattern, string) to match all numbers and however many duplicates follow in a string. Eg. "1222344" matches "1", "222", "3", "...
0
votes
2
answers
191
views
Extract key and identification of a Bitlocker recovery key text file with python
I tried to extract and save the Identifier (Bezeichner) and the Key (Wiederherstellungsschlüssel) by defining a regular expression in python. I need it to work regardless of the language of the text.
...
0
votes
4
answers
180
views
Replace a series of the same character by its number of occurrences in the series [duplicate]
I get a string like this:
AABBBB$CCCDEEE$AABADEE
And I want a result like this:
2A4B$3CD3E$2ABAD2E
To do that, I made a for loop on the string array.
It works well:
import re
string = "AABBBB$...
0
votes
1
answer
110
views
Substitute substring with multiple characters
I am trying to make a string replacement using regex, but I am not able to achieve the expected result.
I have a list of strings ['INSUTRIN 150G','NEUROZINE 30 ML','INSULITROL 30 CAPS'] for example. I ...
1
vote
3
answers
85
views
How to catch a repeating pattern with regex in a string?
I have a bunch of strings like this:
abc#axyz(abc#axyz#a#aabc)abc#axyz. What I need to do is remove all the #a that appear in the text between brackets, while those outside should remain. I've tried ...
-4
votes
1
answer
72
views
Python Regex Query To Pull Out A Name [closed]
I'm trying to pull out just the persons name of the below text, I've tried the below on regex101 with no look so far, any help greatly appreciated.
Owner:\s(.*)
https://regex101.com/r/3xjoAU/2
I'm ...
-2
votes
2
answers
103
views
Specific section of string comma separated [closed]
I have a csv file with some numbers and words. Example,
Header
1 This is the first line.
This is the second line.
3 4 This is the third line.
5 6 7 This is a special line.
Trying to separate these ...