I am using the following regular expression to find roman numerals in a string:
^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$
How can I change it to detect roman numerals preceded or followed by any special character except a period?
I would try this expression:
^[@!#%^*()_&-]?M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})[@!#%^*()_&-]?$
The [@!#%^*()_&-]?
expression at the beginning and at the end match zero or one special characters from your list in the comment.