i have a html file like below:(i’m new in regular expression pattern)
<a href=":$451$142">some thing</a>
<a href=":$14$15">some thing</a>
<a href=":$3$16">some thing</a>
<a href=":$312$17">some thing</a>
how can i replace all the “:$Number$Number” with “#”?
This regex should work:
It yields:
The regular expression:
:\$\d+\$\d+will match any piece of text starting with a:, followed by a$(the$is a special character in regular expression language and thus needs to be escaped with an extra\in front). The$will in turn need to be followed by one or more digits (\d+) which in turn is followed by another:which is followed by one or more numbers (\d+). Please check this tutorial for more information.Although in this case regular expressions did help, it is highly recommended that you do not use them to parse languages. Please use a dedicated framework such as HTML Agility Pack to do any HTML related processes. Take a look here for an example similar to what you seem to be trying to do.