Reputation: 1
I need a regex that finds
width="any number px"
I tried [width=\".*px\"]
To be clear I have file like
1999/xlink" x="0px" y="0px" width="300px" viewBox="0 0
and I need to get
1999/xlink" x="0px" y="0px" viewBox="0 0
Upvotes: 0
Views: 65
Reputation: 432
There are two ways to match 'any number'
the \d
sequence will match any single digit.
[0-9]
will do the same.
Following either of these with +
will match any instance of one or more of these.
So width=\"[0-9]+px\"
will find the matches you want.
Also, containing the entire query in [
]
turns it into a character class, meaning that instead of finding the exact string, it will return any instance of any of the characters in the class. [width]
will find any single instance of the letters w
, i
, d
, t
or h
, regardless of where they are.
Upvotes: 1
Reputation: 425348
You have used a literal in a character class.
Try replacing matches of this:
width="\d+px"\s*
with a blank (to delete it)
Upvotes: 1