regexp-replace

Regex whitelisted url lets blocked urls through on the same line in message

Regex whitelisted url lets blocked urls through on the same line in message Question: So I have a regex expression which blocks URLs in a message, but I want to whitelist the site’s URL. currently it works with any prefix like HTTP://www.example.com and with www.example.com/support/how-do-i-setup-this but if I put another URL behind this then it …

Total answers: 1

List elements should be separated by comma and space in json.dumps

List elements should be separated by comma and space in json.dumps Question: I have a json which contains dictionaries, lists, integers etc. json_str = ”’ { "name": "John", "age": 30, "pets": [ { "name": "Fluffy", "type": "cat", "toys": [ "ball", "string", "box" ] }, { "name": "Fido", "type": "dog", "toys": [ "bone", "frisbee" ] } …

Total answers: 1

Replace ")" by ") " if the parenthesis is followed by a letter or a number using regex

Replace ")" by ") " if the parenthesis is followed by a letter or a number using regex Question: import re input_text = "((PL_ADVB)dentro ). ((PL_ADVB)ñu)((PL_ADVB) 9u)" input_text = re.sub(r"s*)", ")", input_text) print(repr(input_text)) How do I make if the closing parenthesis ) is in front of a letter (uppercase or lowercase) it converts the ) …

Total answers: 3

Match words using this regex pattern, only if these words do not appear within a list of substrings

Match words using this regex pattern, only if these words do not appear within a list of substrings Question: import re input_text = "a áshgdhSdah saasas a corrEr, assasass a saltó sasass a sdssaa" #example list_verbs_in_this_input = ["serías", "serían", "sería", "ser", "es", "corré", "corrió", "corría", "correr", "saltó", "salta", "salto", "circularías", "circularía", "circulando", "circula", "consiste", "consistían", …

Total answers: 1

Python Pandas Extract text between words and symbols with regex

Python Pandas Extract text between words and symbols with regex Question: I am trying to extract certain words between some text and symbol using regex in Python Pandas. The problem is that sometimes there are non-characters after the word I want to extract, and sometimes there is nothing. Here is the input table. Here is …

Total answers: 2

make regex pattern to grab that ends with a period, one or more spaces, or the end of the string

make regex pattern to grab that ends with a period, one or more spaces, or the end of the string Question: import re #regex pattern time_in_numbers = r"(?:por el|entrada el|entrado el|del|)s*(?:a[s|]*.[s|]*m[s|]*.|a[s|]*m[s|]*.|a[s|]*.[s|]*m|a[s|]*m|p[s|]*.[s|]*m[s|]*.|p[s|]*m[s|]*.|p[s|]*.[s|]*m|p[s|]*m|)" #if it detects the regex pattern condition in the input string then it performs a replacement with the re.sub() function input_text = re.sub(time_in_numbers, "replacement!!!", …

Total answers: 2