I want to match n number of characters between a "<" and ">" characters. For example,
I want to be able to match <a href = "image1.jpg">
or
<a href = " http://www.learnmore.com/>
essentially with the same pattern. This is because, the strings I receive might have n number of characters between the special characters. Once I match the pattern which includes the special characters, I will replace it with a blank space(which I am able to do currently---the replacing part.). I need help with the matching part only.
Asked
Active
Viewed 424 times
0

Raghu
- 1,141
- 5
- 20
- 39
-
what have you done so far? can you post it so we can see it? – Hunter McMillen Jul 14 '11 at 18:45
-
\"[^\"]* might work, but parsing HTML with regexp is not robust – Jochen Bedersdorfer Jul 14 '11 at 18:49
3 Answers
0
You can try the following regular expression
(<|<)(.*?)(>|>)
to match against your string (assuming the >
was not a formatting error in your question but the actual content in the string).

Howard
- 38,639
- 9
- 64
- 83
-
I am trying to replace HTML tags with a blank space. If I hard code the HTML tag, I can replace and get the tag, but I am trying to match any tag and so the question on the forum. @Howard, I tried your expression, but it did not work. The > was a formatting error. It should be < or >. – Raghu Jul 14 '11 at 19:04
0
First replace >
with >
and <
with <
. Then do your pattern matching as usual using regex or whatever.

tskuzzy
- 35,812
- 14
- 73
- 140