Bhavesh Nayi Bhavesh Nayi - 1 month ago 10
HTML Question

iOS Use regular expression to remove/replace substring in HTML string

I would like to use regular expression to find given font-family and replace that font-family with mine font; in my string and remove that from so the return value is the original string without new font family applied on it.

Ex.

<span style="font-family: TimesNewRoman; font-size: 12"><p>My text<br /><br />
<span style="font-family: 'Georgia','serif'; color: #1a1a1a;">Description is here</span> Detail description</strong></p>
</span>


Here I want to edit ‘Georgia’ with TimesNewRoman
Note: ‘
Georgia
’ will be
dynamic

Answer

Try this:

(?<=family\:\s)[\s\S]*?(?=[;\s])

Demo: https://regex101.com/r/qv7Zrw/1