Skip to main content

All Questions

Tagged with
0 votes
1 answer
2k views

How can I match a text with colon using regex?

I want to use regex to match any case with only 1 colon in front of a name or behind it, but not a name in between two colons. Matches things like this: name: | :name | name:`asdf` But should not ...
user1094771's user avatar
1 vote
1 answer
2k views

Python2.7 re fullmatch alternatives [duplicate]

Is there a way to match a complete string before python3.4(as they introduced fullmatch() method here.) For eg. If i have a string '12.345' and If i want to check for float with no exponential and i ...
mrig's user avatar
  • 402
0 votes
2 answers
240 views

How to get "clean" match results in Python

I am a total noob, coding for the first time and trying to learn by doing. I'm using this: import re f = open('aaa.txt', 'r') string=f.read() c = re.findall(r"Guest last name: (.*)", string) print "...
Fabio Mancin's user avatar
-1 votes
1 answer
60 views

What does this mean in regular expressions? re.match(r"(^[cf-qs-z]+)", any file name)?

I stumbled upon this code and I do not know what does it match: re.match(r"(^[cf-qs-z]+)", words)
user avatar
-1 votes
1 answer
729 views

Python regex match numbers or nothing

I have strings: 1st one \-1,1\N,0.0464128206,0.1106913625,-0.0261445305\ 2nd one \-1,1\N,0.,0.,0.\ It can be done manually to the \-1,1\N,0.0,0.0,0.0\ but I am trying to make script working ...
XuMuK's user avatar
  • 604
0 votes
1 answer
249 views

Check for Partial Match in 1 List With Partial Match Another List - Possible With List Comprehension?

somewhat of a python/programming newbie here. I have written code that does what I need it to: import re syns = ['professionals|experts|specialists|pros', 'repayed|payed back', 'ridiculous|absurd|...
Darren Haynes's user avatar
0 votes
2 answers
58 views

Python regexp. My small program it is impossible to distinguish letters from numbers

Given the coordinates of the polygon and have to check the input string containing the data coordinates. Here is my code import re t = "(0,0),(0,2),(2,2),(2,0),(0,1)" #tt = "(0,0),(0,2),(2,2),(2,0),(...
user avatar
0 votes
2 answers
734 views

How to have user input state abbreviation and reject or accept in matched with list of abbreviations?

This seems like an easy enough question, but I'm having trouble accomplishing this. Other threads talk about matching and the RE module, but I cannot get this to work. def get_lead_state(): print ...
Reck's user avatar
  • 245
-1 votes
1 answer
467 views

Three way cross matching csv and pulling/printing data in python

I'm trying to do a three way cross-match matching 3 elements between a text file and a CSV and as a result of each match we would be calling/getting certain elements to be appended to a string... ...
Ryflex's user avatar
  • 5,779
0 votes
1 answer
111 views

Appending data to text file dependant on if statment [closed]

I am trying to get a text file automatically updating new class details. # Example variables completed = Yes class = 13A time = 11:00 if completed: # Check data class and time variables against ...
Ryflex's user avatar
  • 5,779
1 vote
2 answers
112 views

How to fix this non working regex pattern matching?

I have a pattern I am trying to match using re.compile. However, I cannot get the script to yield the desired result. Below is an example of some HTML code I am hoping to scrape, from the below HTML I ...
Ryflex's user avatar
  • 5,779
8 votes
3 answers
13k views

Python: How to get multiple elements inside square brackets

I have a string/pattern like this: [xy][abc] I try to get the values contained inside the square brackets: xy abc There are never brackets inside brackets. Invalid: [[abc][def]] So far I've got this:...
Patric's user avatar
  • 2,999