All Questions
36,176 questions
0
votes
3
answers
130
views
How can I remove the brackets and parentheses at the end of words? [closed]
My task is to parse the protein names by removing the brackets and parentheses in the row.
In short, I want to retain the words in front of any parentheses and brackets.
Note that I need to keep ...
-2
votes
1
answer
77
views
How to match numbers from protocol messages to mapping groups in Python?
I have protocol messages from a device in the following format:
560-1X490-3
238-3X458-7
667-9X560-1
170-8X233-8
570-2X155-1
I also have a mapping table like this:
mapping = {
0: [127,136,...
-1
votes
2
answers
93
views
How to search and match and corrent exact word in text file [duplicate]
test.txt file contains 2 misspelled words.
loyai
royai
pain
I want to search for the misspelled words and replace them using dict words_. My problem is if a misspelled word (pai) is part of another ...
-4
votes
0
answers
96
views
Replace incorrect timestamp
I am generating translated text using .webvtt file using Google translator APIs.
For example, I am translating from English to Russian.
While for most languages, it works fine, for some languages like ...
-2
votes
0
answers
28
views
Optional \s inside group not getting captured [duplicate]
I have this string:
"232_0452 Render 2.mov"
And this regex:
.*(\s?[Rr]ender).*
If I execute:
match = re.match(r'.*(\s?[Rr]ender).*', "232_0452 Render 2.mov")
print(match.group(1))...
-1
votes
1
answer
63
views
Strange Regex Behaviour When Using Character Sets ([]) and Em-Dashes using the Pandas 'str.contains()' Function in Python [closed]
For some reason conducting a regex search using the em dash (–) in a character set using the pandas str.contains() function leads to strange results.
I am attempting to sort some military ranks into ...
-4
votes
0
answers
33
views
How to include a variable in a Regex mask with Python [duplicate]
I have a file where I am searching for a certain section of a string (the initial 'C' and either 111 or 112 in this case) and then extracting some bytes further along the string.
I have been using a ...
-2
votes
2
answers
201
views
How to write a regex to match strings where every distinct character occurs the same number of times?
I have a challenge where I need to write a single regex pattern to match strings that satisfy the following property:
Every distinct character in the string appears exactly the same number of times.
...
-4
votes
1
answer
80
views
Having an issue with converting imperial to metric in Python
I'm currently studying engineering and have a lot of books that are in imperial, when I work in metric. Therefore I was trying to write a function in Python that allows me to paste a line of text, ...
0
votes
1
answer
50
views
How to parse link extensions out of a script tag in BeautifulSoup with RegEx in Python
I am trying to parse link extensions out of a script tag in a webpage loaded with requests. I'm able to request the page and load the script tag as a tag element in BeautifulSoup, it looks like this:
{...
0
votes
1
answer
87
views
removing double // comments from json
It turns out there's a format jsonc that allows comments like //this in the JSON along other things. Is it possible to produce a json example with //this type of comments that can make the resulting ...
-5
votes
2
answers
209
views
Convert JSONC to JSON via regex
I have JSONC as input (it is a superset of JSON that supports comments like //this one and /* this one */), and want to transform it into normal JSON (standard) using Python regex, but I'm not sure ...
1
vote
6
answers
152
views
Pairing elements around a separator using Python
I am relatively inexperienced at Python, and I've hit a wall using it to clean some text data into a usable format.
Essentially: I have paired names and values separated by a variable number of ...
-1
votes
1
answer
70
views
Regex capture issues parsing work schedule - other viable options? [duplicate]
I've recently starting learning Python, and I'm creating a small project to track my work commute. I work in aviation, so the basis for this project is parsing my work schedule (roster) to an SQLite3 ...
0
votes
1
answer
87
views
Unwanted ending empty string applying Python Regular Expression split method to test string [duplicate]
In the following Python regular expression, splitting words from a string into a list of substrings, I'm trying to avoid the empty string, '', on the output. Can I adjust the inputs of the regular ...