Skip to main content

All Questions

Tagged with
0 votes
0 answers
11 views

Parsing expression with python: from string to integers [duplicate]

I was trying to split this string in two numbers using multiple delimeters and re library in python Input: "['2 5']" Output [2,5] Code: data = re.split(r"'[ ]'",str(sys.stdin....
Sara's user avatar
  • 1
3 votes
4 answers
756 views

Trim string (both left and right) to nearest word or sentence

I'm writing a function that finds a string near a identical string(s) in a larger piece of text. So far so good, just not pretty. I'm having trouble trimming the resulting string to the nearest ...
Ghoul Fool's user avatar
  • 6,987
2 votes
1 answer
167 views

Split line on comma but not comma within quotes?

I have an input file whose head looks like this: AdditionalCookout.create!([ {day_id: 275, cookout_id: 71, description: "Sample text, that, is ,driving , me, crazy"}, {day_id: 275, cookout_id: 87,...
knave's user avatar
  • 23
0 votes
1 answer
755 views

Why is an additional backslash '\' being added to substring in list when re.split is used? [duplicate]

So I'm trying to solve an issue in my code where an additional backslash is added to a substring(s) in my split list once re.split(regex_pattern, str) is used. The problem goes something like this: ...
Jordan Pagni's user avatar
0 votes
3 answers
69 views

python regex splitting at wrong places

I have the following regex and the input string. pattern = re.compile(r'\s+(?=[^()|^{}|^<>]*(?:\(|\{|\<|$))') string = "token1 token2 {a | op (b|c) | d}" print pattern.split(string) the ...
deathstroke05's user avatar
1 vote
2 answers
106 views

multiple split in string using regex

I have a string : Station Disconnect:1.3.6.1.4.1.11.2.14.11.15.2.75.3.2.0.8 StaMAC:00:9F:0B:00:38:B8 BSSID:00 9F Radioid:2 I want split this string. It look like this - 'Station Disconnect:1.3.6.1....
Prafulla's user avatar
2 votes
1 answer
5k views

Regex to splitstring on date and keep it

I have a string that I want to split on the date: 28/11/2016 Mushroom 05/12/2016 Carrot 12/12/2016 Broccoli 19/12/2016 Potato which should end up as 28/11/2016 Mushroom 05/12/2016 Carrot 12/12/...
Mr Mystery Guest's user avatar
1 vote
1 answer
1k views

Regex to split by square brackets and dots with python and re module

I want to build a regex expression to split by '.' and '[]', but here, I would want to keep the result between square brackets. I mean: import re pattern = re.compile("\.|[\[-\]]") my_string = "a.b....
fenix688's user avatar
  • 2,635
1 vote
4 answers
845 views

split url by python

I have this URL: /drive/rayon.productlist.seomenulevel/fh_refpath$003dfacet_1$0026fh_refview$003dlister$0026fh_view_size$003d100$0026fh_reffacet$003dcategories$0026auchan_page_type$003dcatalogue$...
parik's user avatar
  • 2,415
3 votes
1 answer
253 views

python regex split on repeating character

I have a string for example -------------------------------- hello world ! -------------------------------- world hello ! -------------------------------- ! hello world and I want to be able to split ...
Johnathon64's user avatar
  • 1,320
2 votes
5 answers
2k views

How to split bracketed list in python with regex'?

I am trying to use the re module in python to split a string that represents a list. The list is identified by brackets. Input: "[1]first[2]second[3]third" ... etc Desired output: ['first', '...
Shruf's user avatar
  • 103
1 vote
2 answers
263 views

Split a string with one delimiter but multiple conditions

Good morning, I found multiple threads dealing with splitting strings with multiple delimiters, but not with one delimiter and multiple conditions. I want to split the following strings by sentences:...
fassn's user avatar
  • 359
1 vote
4 answers
1k views

How to split operator and operands in python

My operators are: =, >=, <=, >, < And my expression are as simple as the following samples: string1 = string2 string1=string2 string1= string2 string1 =string2 string1>=string2 string1 ...
Meysam's user avatar
  • 18.2k
5 votes
2 answers
164 views

How to Python split by a character yet maintain that character?

Google Maps results are often displayed thus: '\n113 W 5th St\nEureka, MO, United States\n(636) 938-9310\n' Another variation: 'Clayton Village Shopping Center, 14856 Clayton Rd\nChesterfield, MO, ...
Pyderman's user avatar
  • 16.3k
1 vote
4 answers
57 views

Split string before regex

I'm trying to insert a tab (\t) before a regex, in a string. Before "x days ago", where x is a number between 0-999. The text I have looks like this: Great product, fast shipping! 22 days ago anon ...
Isak's user avatar
  • 545

15 30 50 per page