All Questions
1,394 questions
0
votes
1
answer
48
views
Python split regex matches into two variables
I am trying to split a re.findall match into two variables - one for the date and one for the time - but i can't find a way to split the list up somehow. Any help appreciated!
txt = "created_at': ...
-1
votes
3
answers
256
views
Extract the particular string from text file using python
This is the text file we need to extract the particular string from the text file using python or pandas
Single quotes are present in that string
>>>>>>>>>>>>
[fgh: ...
2
votes
3
answers
184
views
error "unmatched group" when using re.sub in Python 2.7
I have a list of strings. Each element represents a field as key value separated by space:
listA = [
'abcd1-2 4d4e',
'xyz0-1 551',
'foo 3ea',
'bar1 2bd',
'mc-mqisd0-2 77a'
]
Behavior
I need to return ...
0
votes
1
answer
58
views
Imrove regex in Python (2.7) to find short / incomplete UK postcodes
I have a little function that finds full UK postcodes (e.g. DE2 7TT) in strings and returns them accordingly.
However, I'd like to change it to ALSO return postcodes it gets where there's either one ...
1
vote
1
answer
59
views
Edit regex to recognise very short street name or number for Python 2.7 script and avoid fatal attribute error
I have a little script in Python 2.7 with regex that recognises when a street or avenue name is in a string. However it doesn't work for street names of only two letters (OK that's very rare) OR ...
2
votes
1
answer
41
views
Regex get data after |
This is my log
2022-06-29 12:45:04.652 | INFO | product.views.product_view:list:28 - SEARCH | Humana papa
2022-06-29 12:45:04.652 | INFO | product.views.product_view:list:28 - SEARCH | iPhone ...
0
votes
1
answer
149
views
Find IP address in multiple text files and replace it with another string in Python with regex
I have multiple text files as below:
I want to read all of the text files and find the IP value in each file and replace it with the noresult string which is available in the text and save per file in ...
0
votes
1
answer
50
views
I wrote a regex inside of a python script to analyse xml files but sadly its not working
I wrote a script to gather information out of an XML file. Inside, there are ENTITY's defined and I need a RegEx to get the value out of it.
<!ENTITY ABC "123">
<!ENTITY ...
-1
votes
1
answer
37
views
Regex for strings with $ signs, commas and decimals in Python [duplicate]
is it possible to have regex in Python that satisfies all the below STRING conditions?
1,000
1,000.00
$1,000.00
1000
-1000
I have the below but it doesn't satisfy all conditions:
if bool(re.compile(r&...
0
votes
1
answer
2k
views
installing regex on python 2.7 fails with exit status 1 [duplicate]
I want to use the PyTLDR. Someone in the issue section on GitHub stated that the module was written in Python 2. Therefore, I set up a Python 2.7 environment for this project.
My pip version is 20.3 ...
0
votes
1
answer
84
views
what is the best regular expression to replace non numeric character in a string preceded by certain phrase in python?
I have to parse lists of names, addresses, etc. that were OCRed and have invalid/incorrect characters in them and on the state postal code I need to recognize the pattern with a 2 character state ...
2
votes
1
answer
49
views
Python Multiline Replace
I'm trying to get python to run a PowerShell script over Windows RM, because of the encoding I inject the parameters into the top of the file, however this means I need to remove the existing Param ...
2
votes
1
answer
30
views
Get list of struct names that are outside of 'package' and 'endpackage' optional strings
I am trying to get struct names which are outside package and endpackage optional strings.
If there are no package and endpackage strings, then the script should return all the struct names.
This is ...
2
votes
1
answer
328
views
Regex 'sre_constants.error: bad character range' in large regex pattern
The following is the error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/re.py", line 194, in compile
...
0
votes
1
answer
189
views
File extension match in python using RegexMatchingEventHandler
I want to apply basic pattern match on the file extension (.gz) using both RegexMatchingEventHandler and re.
I am getting .gz and .gz.tmp files in my input directory and I only want to pick .gz files.
...