| | |
Matching multiple href="Something.aspx" using RegEx
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
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...
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</a>
</li>
<li>
<as href="About.aspx
Which isn't very useful... can anyone fix my regular expression?
Cheers,
Blackred.

I have a string as such...
ASP.NET Syntax (Toggle Plain Text)
<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</a>
</li>
<li>
<as href="About.aspx
Which isn't very useful... can anyone fix my regular expression?
Cheers,
Blackred.
This station is non-operational.
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.
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.
Last edited by Infarction; Jul 24th, 2007 at 11:37 pm.
![]() |
Similar Threads
- Email send in ASP.NET with "Accept en Deny" link (ASP.NET)
- Why app is looking for "Default.aspx" (ASP.NET)
- Windows 2000 Adv Server and "Printing Subsystem" (Windows NT / 2000 / XP)
- Error loading "bridge.dll" (Viruses, Spyware and other Nasties)
- "Preparing to stand by..." (Windows NT / 2000 / XP)
Other Threads in the ASP.NET Forum
- Previous Thread: Autopostback in Firefox
- Next Thread: Arabic label in ASP.NET dispalys junk chars
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class compatible confirmationcodegeneration content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iis javascript jquery list listbox menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming wizard xml xsl






