Regex to remove `.` from a sub-string enclosed in square brackets

I have this regex in C#:

[.+?]

This regex extracts the sub-strings enclosed between square brackets. But before doing that I want to remove . inside these sub-strings. For example, the string

hello,[how are yo.u?]There are [300.2] billion stars in [Milkyw.?ay].

should become

hello,[how are you]There are [3002] billion stars in [Milkyw?ay].

I am not good at forming regular expression so don’t have any idea of how to modify my regex.

Live example here: https://regex101.com/r/pL5uA1/1


Source: regex

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.