How to change string element position.
Example:
...
<div class="bb" id="aaa">
....
to
...
<div id="aaa" class="bb">
...
or.
...
<div class="bb" style="kk" id="aaa">
....
to
...
<div id="aaa" style="kk" class="bb">
...
So i need to change class="" id="" to id="" class="" in C#. How?
The problem isn’t well defined but if the goal is to simply swap the ‘id’ and ‘class’ properties in a div tag then something like this would work:
Of course this has no error checking, doesn’t react well to strings not strictly formatted like the two examples you gave, is not tolerant of mixed case, etc. Some clever regular expression manipulation could probably accomplish it in a couple lines but it’s unclear that complex, unreadable, hard to maintain regex is what you seek.
If the start and end tags are not static strings, you can also just replace the ‘class’ and ‘id’ properties in-place. I get the impression that there are more details then you’re telling us so it’s quite hard to figure out what you really need.