Tagged Questions
1
vote
1answer
23 views
Regex: dealing with unpredictable inputs: disallowed trailing (but otherwise OK) characters
I'm trying to write a regex that parses <stock ticker> - <company>. The problem is that the inputs are a little unpredictable and the formatting of allowed tickers is broad.
One hyphen in ...
1
vote
3answers
36 views
count the number of images on a webpage, using urllib
For a class, I have an exercise where i need to to count the number of images on any give web page. I know that every image starts with , so I am using a regexp to try and locate them. But I keep ...
1
vote
1answer
27 views
Consecutive uppercase letters regex
I'm trying to use Regular expressions to find three consecutive uppercase letters within a string.
I've tried using:
\b([A-Z]){3}\b
as my regex which works to an extent.
However this only ...
1
vote
1answer
46 views
Easiest way to count cross platform newline patterns
What's the easiest way to count the number of newlines in a string that contains newlines that conform to the cross-platform newline pattern: '\r\n?|\n'.
Say we're skipping white space, or white ...
1
vote
2answers
67 views
Python - How do i write only case statements and instances start with $ from input text file?
I want to only write into a file case line and all instances start with symbol $ in nvp_add function after statement Extended attributes from below input file, so i'm expecting for output like below ...
0
votes
1answer
66 views
Regex expression returns nothing. Why?
This returns nothing?
# Enter your code for "Image Extractor" here.
import re
with open('site.html') as html:
content = html.read()
content = str(content)
...
1
vote
2answers
43 views
Acronyms with Full stops python
I have code which reads a text file and outputs the amount of TLA's in the text as a percentage out of how many lines contain text.
import re
total_lines = 0
matched_lines = 0
for line in ...
1
vote
2answers
69 views
Counting three letter acronyms in a line with Regex Python [on hold]
I need to make a program in python which looks through a given file. Let's say acronyms.txt, and then returns a percentage value of how many lines contain at least 1 three letter acronym.
For example:
...
3
votes
1answer
78 views
RegExp search within part of string
I need some analog of Python method of Regexp object - search. It has three arguments: text, start position and end position and returns Match object that has start and end fields.
I've got a ...
2
votes
1answer
64 views
Using variables in a reg-ex
So I matched (with the help of kind contributors on stack overflow) the item number in:
User Number 1 will probably like movie ID: RecommendedItem[item:557, value:7.32173]the most!
Now I'm trying ...
1
vote
3answers
39 views
Having difficulties writing the right Regular expression
I am trying to match item number in the following text:
User Number 1 will probably like movie ID: RecommendedItem[item:557, value:7.32173]the most!
Here is what I tried:
myfile = ...
1
vote
6answers
107 views
How to replace the colons in this text using Python?
I have a file which looks like
1::12::33::1555
1::412::1245::23444
and so on. I need to get rid of the last argument, and replace the colons with commas. I have tried:
myfile = open('words.txt', ...
2
votes
2answers
3k views
Regex to find urls in string in Python [duplicate]
Possible Duplicate:
What's the cleanest way to extract URLs from a string using Python?
Considering a string as follows:
string = "<p>Hello World</p><a ...
1
vote
3answers
437 views
Python Regex that adds space after dot
How can I use re to write a regex in Python that finds the pattern:
dot "." followed directly by any char [a-zA-Z] (not space or digit)
and then add a space between the dot and the char?
i.e. ...
0
votes
4answers
2k views
How do I split a comma delimited string in Python except for the commas that are within quotes
I am trying to split a comma delimited string in python. The tricky part for me here is that some of the fields in the data themselves have a comma in them and they are enclosed within quotes (" or ...