Tagged Questions
0
votes
4answers
34 views
Extract words surrounding a search word
I have this script that does a word search in text. The search goes pretty good and results work as expected. What I'm trying to achieve is extract n words close to the match. For example:
The ...
2
votes
4answers
45 views
replacing only single instances of a character with python regexp
I am trying to replace single $ characters with something else, and want to ignore multiple $ characters in a row, and I can't quite figure out how. I tried using lookahead:
s='$a $$b $$$c $d'
...
-1
votes
2answers
16 views
Python dir() function with filtering, regex and pretty printing options
dir() is a handy function for developers; which returns a list of names- comprising the attributes of the given object and of attributes reachable from it
(1) I am really interested in seeing only ...
0
votes
4answers
41 views
How can I capture a value from a string and then remove it?
I'm trying to get the number from a string and then remove that number. For instance, I'm going to have a string like '42Xmessage' where 42 is the number I want (it could be any number of digits) and ...
2
votes
2answers
41 views
Regex matching string python
I wanted to match the following string:
strings = iamcool.iplay=ball?end
I want to remove items starting (including the ".") and up till "?", so I want to remove .iplay=ball, so I should have ...
1
vote
3answers
52 views
Python list of strings and list of regexes, clean way to find strings which don't match anything?
So, I have a list of regex patterns, and a list of strings, what I want to do is to say within this list of strings, are there any strings which do not match any of the regexes.
At present, I'm ...
0
votes
5answers
56 views
Divide string by line break or period with Python regular expressions
I have a string:
"""Hello. It's good to meet you.
My name is Bob."""
I'm trying to find the best way to split this into a list divided by periods and linebreaks:
["Hello", "It's good to meet you", ...
-2
votes
1answer
75 views
Why I don't do this regular expression? [on hold]
I have a problem about a regular expression... Python can do the next part of code but if I change the final expression I can't run the code.
In the final line
from bs4 import BeautifulSoup
import ...
1
vote
3answers
39 views
Parsing Text Files with Python 3, Regex and Random Numbers
Here is the input text file I am working with: https://gist.github.com/TestAcc7777/5983147
In the text file, each line after the initial few contains 'CORE X', where X is a number from 1 to 64. Some ...
0
votes
1answer
33 views
What do group() and contents[] mean?
I'am learning about the modules of re and BeautifulSoup. I have a doubt in few lines of the next code. I don't know the use of group() and what's inside of brackets in contents[]
from bs4 import ...
0
votes
4answers
45 views
How to use Python re to parse this string in to list of multiple key value pairs?
I have a string of in Python
str1 = 'abc(1),bcd(xxx),ddd(dfk dsaf)'
How to use re to parse it into an object say 'results' so I can do something like:
for k,v in results:
print('key = %r, value ...
0
votes
3answers
28 views
Regex findall start() and end() ? Python
i'm trying to get the start and end positions of a query in sequence by using re.findall
import re
sequence = 'aaabbbaaacccdddeeefff'
query = 'aaa'
findall = re.findall(query,sequence)
...
2
votes
2answers
44 views
Extract specific values from string
I want to extract all words that have the following label "w=". Example, I will need, " THAT HAVE RECEIVED NO" from the string below.
w="THAT" v="22.23092" a="19.09109" i="3"/>
<r s="1480150" ...
-1
votes
3answers
31 views
Need to extract substring in python with regex
I have a string
('some text', [], ['IP address'])
I want to extract only the 'some text' part from this whole string.
I have no experience with regular expressions, which is needed here.
0
votes
3answers
31 views
Find php string concatenation using python regex
I've recently inherited a number of php files that served as email templates. These php files consist of strings concatenated with php variables. I would like to find all the variable names used in ...