I have strings that includes names and sometime a username in a string followed by a datetime stamp: I want to extract the usernames from this string: I have tried different regex patterns the closest I came to extract was following: Using the following regex pattern: Answer You may get all text up to the first occurrence of -+digits+-: If
Tag: regex
How to get the whole parenthese of a string with maybe infinite level of parentheses inside
I already saw this answer : How to get parentheses inside parentheses but it didn’t really work if I don’t know the number of levels of those parentheses. I’m actually trying to deobfuscate a js file with python, and I have this kind of string that I want to “scrape” : When I run : re.findall(r”String.fromCharCode((.+?))”, content) it returns me
How to get index of regex match of only the matched and included part?
I am doing: I want the index to end at Airport of destination. Desired output: Answer You may move .* into the lookahead to avoid consuming that part of the match: See a regex demo and a Python demo:
Python regular expression SyntaxError: unexpected character after line continuation character
I must have totally messed up my regular expression. I’m trying to find the ID and value in the following str (and eventually will need to find description and it’s value too): But for some reason, I get the above error message. This is my code: I tested in https://pythex.org/ and the regular expression of ID”: “([A-Za-z0-9-]*)” worked, but running
is it possible to use “input variables” in custom order
I’m new in python and regex. I’m trying to make a one-line regex implementation. In first input want to take a text to check, and for second input the regex pattern. Is it possible in python to achieve that? edit: to make question clearer; due to expression console takes first input as regex into code. and second input as text
Why does this pandas str.extract pattern work?
I have a dataframe “movies” with column “title”, which contains movie titles and their release year in the following format: The Pirates (2014) I’m testing different ways to extract just the title portion, which in the example above would be “The Pirates”, into a new column. I used pandas Series.str.extract() and found a regex pattern that works, but I’m not
Match non-capturing group multiple times
I tried really hard to make a good title, but I’m not sure if I’m asking this right. Here’s my best attempt: I’m using Python’s flavor of regex I need to match numbers using named groups: but should not match: my best attempt so far has been: I’m using [sa-z] instead of a word-boundary because 15×20 are two different values.
Regular expression for removing all URLs in a string in Python
I want to delete all the URLs in the sentence. Here is my code: But a URL with “http” is still left in the sentence. How can I fix it? Answer One simple fix would be to just replace the pattern https?://S+ with an empty string: This prints: My pattern assumes that whatever non whitespace characters which follow http:// or
How can I find an IP address in a long string with REGEX?
I want to find out how can I extract only the correct IP address from a very long string. The problem is that my code extract the IP address even if a part of it has more than 3 digits (which is incorrect). I tried to learn more about Python REGEX, but I don’t know exactly how to stop it
Extracting codes with regex (irregular regex keys)
I´m extracting the codes from a string list using coming from the title email. Which looks something like: So far what I tried is: My issue is that, I´m not able to extract the code next to the words that goes before [‘PN’, ‘P/N’, ‘PN:’, ‘P/N:’], specially if the code after starts with a letter (i.e ‘M’) or if it