I have the following string , i tried many many regex to remove comma between a tag text, but not found any regex for removing comma between a tag text. I want that , whenever text inside a tag has comma ,then will be replace by empty string.
<a href="#" class="main">Getty Center, Restaurant at the</a>
i have tried this regex but it is not working, here input is string that contains html.
input = Regex.Replace(input, @"<a(\s+[^>]*)?>[^\w\s]</a(\s+[^>]*)?>", "");
Please help me out. Thank You
You can use the Regex to find and modify the content of the tag like so.
The loop is in place to catch multiple tags in the same string. The Regex however is fairly naive. It will mess with tags nested inside the A tag, and will parse incorrectly if a
>is in any of the attributes. (Though that would probably be bad HTML anyway.) A proper HTML parser is recommended for this reason.