regex help

S

Sunny

Hi,
I know that this is not the very right group, but I can not find better,
and I have seen a lot of regex experts to answer, so I'll give a shot:

Lets have this string:
"<table name='xxx'><br>\nMY_TEXT\n<\table><p>"

please note the new line characters.

So, using a regex like:
"</?table.*>"

will find these:

"<table name='xxx'><br>" and
"<\table><p>"

How should like a regex to get only the table tags? I want to leave <br>
and <p> unmatched? How to stop the match to the first occurrence of ">",
not the last one?

I.e. if I replace the match with an empty string, I want to receive:
"<br>\nMY_TEXT\n<p>",

but not what I have now:
"\nMY_TEXT\n"


Cheers
Sunny
 
S

Sunny

I found it:

"</?table.*?>"

The second ? makes lazy *, i.e. as few repeats as possible.

Thanks for reading, and hope this can help someone.

SUnny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top