// It will include the space before as well (if it has one) /(^| )(https?://)?(www.)?[-a-zA-Z0-9@:%._+~#=]{1,256}.[a-zA-Z0-9()]{1,8}([-a-zA-Z0-9()@:%_+.~#?&//=]*)/gi