I’m finding it difficult to complete this regex. The following regex checks for the validity of comma-separated strings: ^(w+)(,s*w+)*$ So, this will match the following comma-separated strings: Then, I can do the same for non-characters, using ^(W+)(,s*W+)*$, which will match: I would like to create a regex which matches strings which include special characters, and hyphens and underscore, e.g. foo-bar,
Tag: string
Draw a simple box around a string
I’m trying to learn python, and one of the “tasks” asks me to draw a box around a string. For some reason, I can’t come to a solution. This is supposed to be super basic so we can’t use functions and loops etc. Here’s the task: (I’m stuck on question 2) Load a string via the input () function, and
Flipping a binary in a string
I am new to python and coding in general. So what I am trying to achieve is to flip each bit in a binary string (for eg. if I input ‘110’ the output should be ‘001’). I specifically need to use the while loop and I need to define it as a function. Here is what I’ve tried so far:
Compare string like ‘1,2,3’ and ‘3,1,2’ to be set as equals in Python [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I have a strings like ‘1,2,3’ and ‘3,1,2’in a list, is there any way to compare these two strings and check that they are the
Finding a specific string in a Dataframe column
I’m trying to retrieve one row of data from my Dataframe created from a csv file accessed via URL. I’m using… df1[‘Statistic Element’].str.contains(‘Mean rainfall’) …to determine the row containing the data I require however python does not recognize the .str element of the dataframe? DF1.info() The code works fine using a test dataframe so I’m wondering if there is a
How to extract certain string out of long url kind of string in python using pandas
How to use regex in pandas to extract below field. the below is one of my pandas dataframe column value, but i wanted to only extract ‘eastus’ and keep it as value for this field. how to filter this. this position is always fixed Sample df: command i tried: but its not working Error: any suggestion please Answer
Splitting list of strings based on a character in each string ( Python )
So i have a list of strings that looks like this : This is how the list is generated and made readable (“video” is a list of selenium webelements ) : What i want to do is SPLIT this list into two other lists based on ONE specific character in each element like so : My end goal is to
Searching over a list of individual sentences by a specific term in Python
I have a list of terms in Python that look like this. As well as a list of individual sentences that may contain the name of that fruit in a data frame. Something similar to this: And I want to take the sentences in the review column, match them with the fruit mentioned in the text and print out a
Call many python functions from a module by looping through a list of function names and making them variables
I have three similar functions in tld_list.py. I am working out of mainBase.py file. I am trying to create a variable string which will call the appropriate function by looping through the list of all functions. My code reads from a list of function names, iterates through the list and running the function on each iteration. Each function returns 10
Printing wrong text in list in Python
This is My Code. When I am trying to add backslash in the list of strings with the following code. list = [‘\’ + item for item in res] This Will remove + From the list and add ‘\’ in the starting of the code. I am also tried with r’\’ But this is not worked for me. Please