Wednesday, 15 August 2012

Regex for inputing attribute inside tag -



Regex for inputing attribute inside tag -

i need set new attribute within particular tag doesn't have already.

i've found similar needs helps locate tags, new regex , having problem it.

here, master @ridgerunner nicely explains how find it. now, found hundreds of ocurrences along code. exhausting manually input missing attribute in tags.

is there chance eclipse replace tool may help me? how?

thanks

if set \1 in replace field, replaced whatever first bracket in regex matches. example, if utilize regex in find field

(<input )

and text in replace field

\1name="abc"

, replace <input instances <input name="abc". likewise, using \2 re-create sec bracket, etc.

this should plenty add together attributes, careful of elements have attribute. if case can search replaced text 1 time again elements have attribute defined twice, this:

(<input )name="abc"(.*? name=.*?>)

and replace with

\1\2

this remove new attribute added elements had attribute defined.

regex attributes tags xhtml pattern-matching

No comments:

Post a Comment