Skip to main content

All Questions

Tagged with
1 vote
2 answers
553 views

i want extract address using regex in python where i can use a lookbehind so that i get the preceding 3-4 strings that hold the address

text = ' My uncle is admitted in the hospital. the address of the hospital is \n Apollo Health City Campus, Jubilee Hills, Hyderabad - 500 033. ' now i am using this as my regex expression but just ...
guati dibba's user avatar
0 votes
2 answers
318 views

Using re.findall but without parenthesis in Python

I have a variable in python x, storing below values : XYZ (APABC01) ABC (ACACA18) GHI (ABUAD21) I want only the part which is inside the parenthesis as a list. I have used below regex and I almost ...
ACSO's user avatar
  • 41
-1 votes
2 answers
601 views

Extract 15 digit string from text using regex (re.findall) in python [duplicate]

My input is-- Text = "My name is Alex , house no - 254456845 with mobile no. +91-11-22558845 and my account no. is - AB12569BF214558." Now I want to use regex (re.findall) on my input text ...
Lokesh Choraria's user avatar
1 vote
2 answers
45 views

Extract substring between two specified substrings using re.search(pattern, text) in Python

I have a string like, "ENST00000260682_3_4_5_6_7_8_9_BS_673.6". I have to use regex in re.search() to extract a substring and write this into a list like this, [3, 4, 5, 6, 7, 8, 9], in Python. I ...
User's user avatar
  • 398
0 votes
2 answers
178 views

How to match exact words in Python?

I'm new to python. I have a set of strings in multiple text file. There i will more that 100 files. cool.add.odd.inn.txt weather: cool.add.odd.inn blab: name= hello.add.COPY_HI blab: name= hello....
Darshan Mahalinge Gowda's user avatar
1 vote
1 answer
989 views

Python regex replace numbers < 100 with '100 BLOCK', else replace last two digits with '00 BLOCK'

I am using Python 2.7.13 to clean some data. I have a list of numbers that if strings starting with numbers. If the starting number is less than 100, I need to replace it with '100 BLOCK'. If the ...
sushi's user avatar
  • 310
0 votes
4 answers
547 views

How to remove dictionary items in list based on values in string

I'm busy extracting data with python 2.7 So far I got a list with dictionaries as items. For 2 days I cannot get any further with this. Data: list = [ { 'displayName': '#12', '...
StoneAgeRebel's user avatar
-1 votes
1 answer
453 views

Why can't I match True / False value in an IF statement? [duplicate]

I'm trying to match the output of a re.search against a list and run code if the IF statement allows. However, even if I tell the IF statement to match True or False, the IF statement never proceeds. ...
MrU's user avatar
  • 127
1 vote
2 answers
2k views

Split string on comma not present in round brackets or curly brackets in python

Below is the string I am trying to split on comma. If comma is present inside () or {}, that string shouldn't be splitted. I am splitting using below code: for now it's only taking care of (), how ...
zubug55's user avatar
  • 729
0 votes
1 answer
55 views

Split an expression into list based on some silly conditions

I have a some expression like below: ^f04[^z]*$ ^f00bar$,^.*f04.*&~(.*z.*)$ AND foo bar OR f04ba So, what i want to do here is: if the 2 consecutive words or words in the form of regex are ...
zubug55's user avatar
  • 729
-2 votes
4 answers
2k views

python - How to count the number of occurances of sub-string in a list

if I have a list like list = ['helloA', 'hiA', 'helloB', helloC'] I would like to count the number of sub-string 'hello' occurances in that list. Edit: Actually I already had a ways to count it ...
jted95's user avatar
  • 1,144
1 vote
1 answer
1k views

(Python) Identify the missing character and replace with NA

my_string = " Name Last_Name Place" my_string_another = "Aman Raparia India" I have two string which I have provided above and this is not an output ...
Aman Raparia's user avatar
0 votes
1 answer
720 views

How do i extract specific characters from elements in a list in python?

['PRE user_1/\n', '2016-11-30 11:43:32 62944 UserID-12345.jpg\n', '2016-11-28 10:07:24 29227 anpr.jpg\n', '2016-11-30 11:38:30 62944 image.jpg\n'] I have a list of string and i want to ...
Milap Jhumkhawala's user avatar
0 votes
2 answers
147 views

Python - expanding the range between dot dot (id1..id2)

Suppose i have a list of ids like: ids= 1/1/n1..1/1/n5 , 1/1/x1 , 1/1/g1 Expected output: 1/1/n1 , 1/1/n2 , 1/1/n3 , 1/1/n4 , 1/1/n5 ,1/1/x1, 1/1/g1 Means wherever i finds 'ids..ids', i will fill ...
Dave's user avatar
  • 221
2 votes
1 answer
366 views

best way count the number of matches between the list and the string in python

What is the best way to count the number of matches between the list and the string in python?? for example if I have this list: list = ['one', 'two', 'three'] and this string: line = "some one ...
b24's user avatar
  • 2,473

15 30 50 per page