regex parsing a string with an optional substring and preserve both -


i have following strings, substring between square brackets optional, come in 2 variations:

standard eastern time[hh:mm]

standard eastern time

i'd use regular expression both "standard eastern time" , hh:mm (if [hh:mm] exists)

i've tried various regex:

(.+)[(.*)]

does not works when [hh:mm] exists

(.+)([(.*)])?

just includes everything

any or pointers appreciative.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -