I have a database that had data parsed into it. During parseing ampersands and semi-colons were removed which messed up a bunch of HTML Entities.
For example, I now have data stored like so:
#7779avaf#299
Which should be:
ṣavafī
I started replacing some of these like so:
REPLACE ( FIELD1, '#7779' , 'ṣ' )
However, I have to write a new replace for every entity. I’m not very good with RegEx. Is there a way I can match all possible combinations of # followed by 3 or 4 digits and replace it with &# followed by the same 3 or 4 digits and then a semi colon?
Here is a regular expression to extract all the matching target text:
You can then use the list it would generate to generate your
REPLACEstatements, or figure out the syntax to use the backtracking feature of your regular expression engine to dynamically wrap the matched group with a∧T-SQL Regular Expression Workbench has some examples of how to
SELECTusing a regular expression like above. As well as how toREPLACE.