regex - Regular expression for XML element with arbitrary attribute value -
i'm not confortable regex.
i have text file lot of data , different formats. want keep kind of string.
<data name=\"myproptertyvalue\" xml:space=\"preserve\"> only value of name property can change.
so imagined regex <data name=\\\"(.)\\\" xml:space=\\\"preserve\\\"> it's not working.
any tips?
your (.) capture single character; add quantifier + (“one or more”):
/<data name=\\"(.+)\\" xml:space=\\"preserve\\">/ depending on input (element element or entire document) , on want achieve (removing/replacing/testing/capturing), should make regex global (by adding g flag), applied not once. also, should make + quantifier lazy adding ? it. make non-greedy, because want capturing stop @ ending quote of attribute (like quotation mark: [^"]). then, this:
/<data name=\\"(.+?)\\" xml:space=\\"preserve\\">/g
Comments
Post a Comment