regex - Find and replace to remove the icon in all my forms -


i'm using visual studio, , remove icon in forms on code. icon embedded in resx files, used following regular expression find icon, used find , replace:

\<data name=\"\$this\.icon\".+\n(.*\n)*^.+ree=\n(.*\n)(.*\n) 

the icon present in resx files following code:

      <data name="$this.icon" type="system.drawing.icon, system.drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">         <value>            aaabaagaicaqaaeabadoagaahgaaabaqeaabaaqakaeaag4daaawmaaaaqaiakgoaacwbaaaicaaaaea            ...            regaaaxbgagsqyabrehaaaxbwaosqeahrehgh6xb+d+sqf//ree=         </value>       </data> 

it works, performance bad. please, find faster regular expression?

thanks in advance.

description

this expression will:

  • find data tags have attribute of name=$this.icon
  • avoid of sticky problems using regex reading non regular markup languages

<data\b(?=\s)(?=(?:[^>=]|='[^']*'|="[^"]*"|=[^'"][^\s>]*)*?\sname="\$this\.icon")(?:[^>=]|='[^']*'|="[^"]*"|=[^'"\s]*)*"\s?\/?>(?:(?!<\/data>)[\s\s])*?<\/data>

enter image description here

example

live example: http://www.rubular.com/r/fqdoi8h27x

sample text

note first data tag has difficult edge cases

<data onmouseover=' name="$this.icon" ; funreplace("</data>", name) ; ' type="system.drawing.icon, system.drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">         <value>            aaabaagaicaqaaeabadoagaahgaaabaqeaabaaqakaeaag4daaawmaaaaqaiakgoaacwbaaaicaaaaea            ...            regaaaxbgagsqyabrehaaaxbwaosqeahrehgh6xb+d+sqf//ree=         </value>       </data> <data name="$this.icon" type="system.drawing.icon, system.drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">         <value>            aaabaagaicaqaaeabadoagaahgaaabaqeaabaaqakaeaag4daaawmaaaaqaiakgoaacwbaaaicaaaaea            ...            regaaaxbgagsqyabrehaaaxbwaosqeahrehgh6xb+d+sqf//ree=         </value>       </data> 

matches

[0] => <data name="$this.icon" type="system.drawing.icon, system.drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">     <value>        aaabaagaicaqaaeabadoagaahgaaabaqeaabaaqakaeaag4daaawmaaaaqaiakgoaacwbaaaicaaaaea        ...        regaaaxbgagsqyabrehaaaxbwaosqeahrehgh6xb+d+sqf//ree=     </value>   </data> 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -