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
Post a Comment