regex: replacing one group of a match

D

darrel

I'm new to .net's regex capabilities. I've made a regex:

dim r as new regex( _
"(?<tagOpening>(<))" & _
"(?<theTag>(" & tagToFind & "))" & _
"(?<anything>(.[^>/]*))" & _
"(?<theAttribute>(" & attributeToFind & "))" & _
"(?<theEqualsSign>((\s*)=(\s*)))" & _
"(?<theAttributeValue>((.[^\s/>]*)))" _
, RegexOptions.IgnoreCase)

This should work.

Now, I have a string that I'd like to apply the above regex to, and then
replace one of the named groups with a new value. Can I just do this:

dim caption as String = r.replace(theAttributeValue, "10")

If so, then I think I just need the proper syntax to select the named group
in the regex.

However, I have a hunch that I need to do more than this. Maybe create a
match?

-Darrel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top