Skip to main content

All Questions

Tagged with
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 ...
Ssong's user avatar
  • 468
-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,...
Rayan Humane's user avatar
-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 ...
bob_the_bob's user avatar
-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 ...
user4315564's user avatar
-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))...
Malcolm Wright's user avatar
-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 ...
Noot's user avatar
  • 1
-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 ...
WillH's user avatar
  • 295
-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. ...
Jayce Dang's user avatar
-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, ...
Hidde's user avatar
  • 7
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: {...
Brandon Benton's user avatar
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 ...
martin's user avatar
  • 1,002
-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 ...
martin's user avatar
  • 1,002
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 ...
user30640814's user avatar
-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 ...
bergand's user avatar
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 ...
Lee McNally's user avatar

15 30 50 per page
1
2 3 4 5
2412