954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Matching multiple href="Something.aspx" using RegEx

This is really a regular expression question opposed to a .NET but I can't see any forum that specialises in that kind of thing, so as I'm using ASP.NET I figured I'd post it here ;)

I have a string as such...

<ul>
  <li>
    <a href="Welcome.aspx">Welcome</a>
  </li>
  <li>
    <as href="About.aspx">About us</a>
  </li>
</ul>

And I want to match each of the href="*" and replace them, however my regular expression skills are non-existant! I've got this far...

href=".*\.aspx" but that returns just one match:

href="Welcome.aspx">Welcome


Blackred
Newbie Poster
10 posts since Apr 2007
Reputation Points: 10
Solved Threads: 2
 

regex: href=\"[^\"]\.aspx\"

Yours was matching from the first href to the end of the second one because of the .* whereas mine allows anything except for a closing quote (and therefore stops at the end of the first one). It's not as anal as I usually get with regex, but as long as you have well-formed XHTML it should work.

Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You