regex - python - How to know what re used to split a string? -


the code below lets user input 2 names of movies separated either &, | or ^:

query = raw_input("enter query:") movie_f = re.split('&|\^|\|', query)[0].strip() movie_s = re.split('&|\^|\|', query)[1].strip() 

i want know re has used separate string (&, | or ^). how can that?

if group regex return items split every second item.

>>> query '&foo^bar' >>> re.split(r'(&|\^|)', query) ['', '&', 'foo', '^', 'bar'] 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -